Details
-
Bug
-
Resolution: Fixed
-
P3
-
8
-
None
-
b106
-
generic
-
generic
Description
Test script:
<pre>
var m = new javax.script.ScriptEngineManager();
var e = m.getEngineByName("nashorn");
function func(x) {
print("func: " + x);
}
e.put("func", func);
e.invokeFunction("func", "hello");
var obj = e.eval("({ foo: func })");
e.invokeMethod(obj, "foo", "world");
</pre>
Exception trace is as follows:
Exception in thread "main" java.lang.RuntimeException: java.lang.NoSuchMethodException: No such function func
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:368)
at jdk.nashorn.tools.Shell.apply(Shell.java:386)
at jdk.nashorn.tools.Shell.runScripts(Shell.java:315)
at jdk.nashorn.tools.Shell.run(Shell.java:179)
at jdk.nashorn.tools.Shell.main(Shell.java:143)
at jdk.nashorn.tools.Shell.main(Shell.java:122)
Caused by: java.lang.NoSuchMethodException: No such function func
at jdk.nashorn.api.scripting.ScriptObjectMirror.call(ScriptObjectMirror.java:92)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:434)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:200)
at jdk.nashorn.internal.scripts.Script$test.runScript(test.js:9)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:518)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:204)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:364)
... 5 more
<pre>
var m = new javax.script.ScriptEngineManager();
var e = m.getEngineByName("nashorn");
function func(x) {
print("func: " + x);
}
e.put("func", func);
e.invokeFunction("func", "hello");
var obj = e.eval("({ foo: func })");
e.invokeMethod(obj, "foo", "world");
</pre>
Exception trace is as follows:
Exception in thread "main" java.lang.RuntimeException: java.lang.NoSuchMethodException: No such function func
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:368)
at jdk.nashorn.tools.Shell.apply(Shell.java:386)
at jdk.nashorn.tools.Shell.runScripts(Shell.java:315)
at jdk.nashorn.tools.Shell.run(Shell.java:179)
at jdk.nashorn.tools.Shell.main(Shell.java:143)
at jdk.nashorn.tools.Shell.main(Shell.java:122)
Caused by: java.lang.NoSuchMethodException: No such function func
at jdk.nashorn.api.scripting.ScriptObjectMirror.call(ScriptObjectMirror.java:92)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:434)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:200)
at jdk.nashorn.internal.scripts.Script$test.runScript(test.js:9)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:518)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:204)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:364)
... 5 more