FULL PRODUCT VERSION :
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) Client VM (build 25.25-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Ubunbtu 14.04
A DESCRIPTION OF THE PROBLEM :
If a Java method has arguments of type Object, nashorn javaScript calling said java method will try to pass objects as an unusable type.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Arg is (java.util.Map | jdk.nashorn.api.ScriptObjectMirror)
ACTUAL -
Arg is jdk.nashorn.internal.scripts.JO4@<hash_code>
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public static class Helper {
public void doObj(Object arg) {
System.out.println("Arg is " + arg);
}
}
public static void main(String args[]) throws Exception {
ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
engine.put("helper", new Helper());
engine.eval("var x = {foo:\"bar\"};\n" +
"helper.doObj(x);\n");
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Avoiding parameter types of 'Object' in Java when I know JavaScript will pass js-Objects to Java method.