Problem with interoperability with JavaFX WebEngine

A. Sundararajan sundararajan.athijegannathan at
Fri Mar 27 12:52:25 UTC 2015

Browser's DOM objects (like WebEngine's) implement 
netscape.javascript.JSObject interface. Such objects are treated 
specially by nashorn's linker.

is the dynalink linker that handles such objects. JSObject.getMember, 
putMember, call are used to provide property, call access seamlessly.

Please check out this example:

So, what you're seeing is a bug in the way that linker works.  Let me 
check out and file a bug.


On Friday 27 March 2015 04:41 PM, David P. Caldwell wrote:
> So it's very cool, and unexpected, that JavaScript objects obtained
> from a JavaFX WebEngine show up as something like ordinary Nashorn
> objects in Nashorn scripts. That's an unexpected bonus (I was planning
> on using .setMember() and all that stuff from
> netscape.javascript.JSObject).
> The objects behave a bit strangely, though. So I've got a couple of
> bug reports, I guess.
> Here's a script that demonstrates the ones I've found so far:
> var WebEngine = Java.type("javafx.scene.web.WebEngine");
> var engine = new WebEngine();
> var window = engine.executeScript("window");
> print("foo = " +;
> print("typeof( = " + typeof(;
> if ( {
>      print(" is truthy");
> }
> Output:
> $ /usr/lib/jvm/jdk1.8.0_40/bin/jjs -fx nashorn.js
> foo = undefined
> typeof( = string
> is truthy
> I actually am using a much more complicated embedding that is done
> from Java, so I can tell you the problem is not in the implementation
> of the -fx flag.
> Other than that, I can't see much; I haven't delved into the Nashorn
> code, let alone whatever magic enables this.
> -- David.

More information about the nashorn-dev mailing list