JavaAdapter - extend class?
Bruno Borges
bruno.borges at oracle.com
Fri Dec 21 13:18:29 PST 2012
So, like I said: Nashorn does not support extending a class.
This is bad because sometimes we have abstract classes that need to be
implemented on the Javascript side.
Is there any plan to provide this feature?
On Fri 21 Dec 2012 07:16:05 PM BRST, Jim Laskey (Oracle) wrote:
> 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)
>>
>
--
--
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