FULL PRODUCT VERSION : java version "1.8.0_60" Java(TM) SE Runtime Environment (build 1.8.0_60-b27) Java HotSpot(TM) Client VM (build 25.60-b23, mixed mode) ADDITIONAL OS VERSION INFORMATION : Microsoft Windows [Version 6.3.9600] A DESCRIPTION OF THE PROBLEM : While executing a JavaScript code with nashorn executable (jjs.exe), an exception is thrown. Probably it caused by a dead code elimination while pre-processing the JavaScript file. This bug might be related to previously reported bug (reported by me few days ago, JI-9023716). STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : save the attaches source code as program.js and run in windows command: jjs.exe program.js EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - in out ACTUAL - in Exception in thread "main" java.lang.ClassCastException: Cannot cast jdk.nashorn.internal.runtime.Undefined to jdk.nashorn.internal.runtime.ScriptFunction at java.lang.invoke.MethodHandleImpl.newClassCastException(Unknown Source) at java.lang.invoke.MethodHandleImpl.castReference(Unknown Source) at jdk.nashorn.internal.scripts.Script$code.:program(code.js:11) at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:640) at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:228) at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393) at jdk.nashorn.tools.Shell.apply(Shell.java:397) at jdk.nashorn.tools.Shell.runScripts(Shell.java:326) at jdk.nashorn.tools.Shell.run(Shell.java:172) at jdk.nashorn.tools.Shell.main(Shell.java:136) at jdk.nashorn.tools.Shell.main(Shell.java:112) ERROR MESSAGES/STACK TRACES THAT OCCUR : Exception in thread "main" java.lang.ClassCastException: Cannot cast jdk.nashorn.internal.runtime.Undefined to jdk.nashorn.internal.runtime.ScriptFunction at java.lang.invoke.MethodHandleImpl.newClassCastException(Unknown Source) at java.lang.invoke.MethodHandleImpl.castReference(Unknown Source) at jdk.nashorn.internal.scripts.Script$code.:program(code.js:11) at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:640) at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:228) at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393) at jdk.nashorn.tools.Shell.apply(Shell.java:397) at jdk.nashorn.tools.Shell.runScripts(Shell.java:326) at jdk.nashorn.tools.Shell.run(Shell.java:172) at jdk.nashorn.tools.Shell.main(Shell.java:136) at jdk.nashorn.tools.Shell.main(Shell.java:112) REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- print("in"); var v1; function f1() { v1 = 1; return true; (function () { var v1; })(); } f1(); print("out"); ---------- END SOURCE ----------
|