Extending a Java class

Sundararajan Athijegannathan sundararajan.athijegannathan at oracle.com
Wed Oct 3 12:32:06 UTC 2018

protected methods of super class are made public in the generated script 
subclass. Java.super should have worked. If you can submit a simpler 
test case, it may be possible to see what's happening..


On 02/10/18, 3:52 PM, Axel Dörfler wrote:
> Hi Sundar,
> Am 01/10/2018 um 05:00 schrieb Sundararajan Athijegannathan:
>> In your example, it seems you're trying to add a new method to the 
>> subtype created in script. That is not supported. You can override 
>> existing methods of superclass  - but not add a new method to the 
>> Java type.
> Bummer! resourcetrysuggester.js added new fields to a Java type, so I 
> thought it should work.
>> Note that all super methods (including protected ones) are available 
>> via Java.super. For example, you can invoke 
>> Java.super(filter).fireMatchNode(). So the workaround for this case 
>> would be add utility function outside for "setEnabled".
> This does sound like an acceptable work-around, however, it doesn't 
> seem to work:
> TypeError: Java.super(filter).fireMatchNone is not a function
> I guess there is no way to call protected methods from JavaScript 
> then? Well, I guess reflection will work.
> Kind regards,
>    Axel.

More information about the nashorn-dev mailing list