JSObject and delegation to other java classes
sundararajan.athijegannathan at oracle.com
Mon Jul 21 15:52:04 UTC 2014
You can't "take" java method away from object and then "apply" it later
(like you do with Java reflection). Also, there is not "Function" like
"apply" for Java methods. If you switch on method names and have
multiple call sites, i.e., one each for each "hot" methods and have
default for the rest, that should help.
On Monday 21 July 2014 09:04 PM, Marc Downie wrote:
> On Mon, Jul 21, 2014 at 6:11 AM, A. Sundararajan<
> sundararajan.athijegannathan at oracle.com> wrote:
>> Will this sample of any help to you?
> It is! Many thanks.
> What stopped me getting there myself? Well I fell into this trap: assigned
> methods from the fallback class to temporary variables doesn't work
> var ArrayList = Java.type('java.util.ArrayList')
> var al = new ArrayList()
> al.size() // WORKS, returns zero
> var sz = al.size // works, sz is not undefined or null
> sz() // throws ClassCastException
> Obviously in your code you just do the lookup multiple times, but out of
> interest: is there anything I can do with sz to call the underlying method?
> What's it even for?
More information about the nashorn-dev