Extending a Java class
Axel Dörfler
axeld at pinc-software.de
Tue Oct 2 10:22:26 UTC 2018
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