JavaAdapter - extend class?

Jim Laskey (Oracle) james.laskey at oracle.com
Fri Dec 21 13:16:05 PST 2012


Absolutely.  Here is the comment from the source.

 This class implements Rhino-like JavaAdapter to help implement a Java
 interface in JavaScript. We support this using Invocable.getInterface.
 Using this JavaAdapter, script author could write:

    var r = new java.lang.Runnable() {
                run: function() { script... }
            };

    r.run();
    new java.lang.Thread(r).start();

 Note that Rhino's JavaAdapter support allows extending a Java class and/or
 implementing one or more interfaces. This JavaAdapter implementation does
 not support these.

If you looked at the twitter example on the blog you'll see another application.

	https://blogs.oracle.com/nashorn/entry/nashorn_in_the_twitterverse_continued

Cheers,

-- Jim




On 2012-12-21, at 4:56 PM, Bruno Borges <bruno.borges at oracle.com> wrote:

> On Mozilla Rhino, the JavaAdapter offers the capability of extending from concrete classes, and also implementing more than one interface.
> 
> Will Nashorn offer this same capability?
> 
> I ask this because the modified version of Rhino that comes with JRE does *not* offer this.
> 
> Thanks
> 
> -- 
> Bruno Borges
> Principal Product Manager | JavaEE WebLogic GlassFish
> Oracle LAD PM Team        | Cloud Application Foundation
> +55 11 5187 6514 (Work)   | +55 11 99564 9058 (Mobi)
> 



More information about the nashorn-dev mailing list