File: list_conversion.js
Arrays = java.util.Arrays;
print(Arrays.asList("hello world".split(' ')));
The above script works fine with jdk8u31 but fails on jdk8u40 early access build and jdk9 with the following stack trace:
Exception in thread "main" java.lang.ClassCastException: Cannot cast jdk.nashorn.api.scripting.ScriptObjectMirror to [Ljava.lang.Object;
at java.lang.invoke.MethodHandleImpl.newClassCastException(MethodHandleImpl.java:361)
at java.lang.invoke.MethodHandleImpl.castReference(MethodHandleImpl.java:356)
at jdk.nashorn.internal.scripts.Script$list_conversion.:program(list_conversion.js:2)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:636)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:229)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:387)
at jdk.nashorn.tools.Shell.apply(Shell.java:394)
at jdk.nashorn.tools.Shell.runScripts(Shell.java:323)
at jdk.nashorn.tools.Shell.run(Shell.java:169)
at jdk.nashorn.tools.Shell.main(Shell.java:133)
at jdk.nashorn.tools.Shell.main(Shell.java:112)