Is it worked Nashorn JS object to java.util.Map?

Viewed 7685

I have java method

void someMethod(String str, Map map) {
    ...
}

From JS call this method

var map = new Object()
map.key1 = "val1"
...someMethod(str, map)

Exception:

java.lang.NoSuchMethodException: None of the fixed arity signatures
[(java.lang.String, java.util.Map)] of method org.prjctor.shell.Bash.eval
match the argument types [java.lang.String, jdk.nashorn.internal.scripts.JO]

But in Nashorn docs "Mapping of Data Types Between Java and JavaScript" said "Every JavaScript object is also a java.util.Map so APIs receiving maps will receive them directly".

What am I doing wrong?

2 Answers
Related