Javascript object to Map

Júnior fjunior87 at
Wed Sep 25 13:35:49 PDT 2013


Reading the point 3.10 from this link:

If I didn't misunderstand that, if I have a javascript object I can pass it
to a java method that accepts a java.util.Map.

So, this code is supposed to work:


var HashMap = Java.type("java.util.HashMap");

var map = new HashMap();



But when executing this using the jjs I got this error:

*"Exception in thread "main" java.lang.ClassCastException: Cannot cast
jdk.nashorn.internal.scripts.JO to java.util.Map"*

Is this the expected behavior?

Francisco Ribeiro Junior

More information about the nashorn-dev mailing list