JDK-8028161 : nashorn: src/jdk/nashorn/api/scripting/ScriptEngineTest.java
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 8
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2013-11-11
  • Updated: 2013-12-05
  • Resolved: 2013-11-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8 b119Fixed
Description
The above test fails on Solaris and it seems to work fine on Linux, here is the stack trace
I have attached the jtr as well for reference:

test public void jdk.nashorn.api.scripting.ScriptEngineTest.scriptObjectAutoConv ersionTest() throws javax.script.ScriptException: failure
java.lang.ClassCastException: Cannot cast jdk.nashorn.internal.scripts.JO4 to jd k.nashorn.api.scripting.JSObject
        at sun.invoke.util.ValueConversions.newClassCastException(ValueConversio ns.java:461)
        at sun.invoke.util.ValueConversions.castReference(ValueConversions.java: 456)
        at jdk.nashorn.internal.scripts.Script$\^eval\_.runScript(<eval>:1)
        at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunction Data.java:498)
        at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.jav a:207)
        at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:3 78)
        at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptE ngine.java:544)
        at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptE ngine.java:526)
        at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptE ngine.java:522)
        at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngin e.java:193)
        at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
        at jdk.nashorn.api.scripting.ScriptEngineTest.scriptObjectAutoConversion Test(ScriptEngineTest.java:532)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocat ionHelper.java:80)
        at org.testng.internal.Invoker.invokeMethod(Invoker.java:715)
        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:907)
        at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1237)
        at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWork er.java:127)
        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
        at org.testng.TestRunner.privateRun(TestRunner.java:767)
        at org.testng.TestRunner.run(TestRunner.java:617)
        at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
        at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
        at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
        at org.testng.SuiteRunner.run(SuiteRunner.java:240)
        at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:51)
        at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:85)
        at org.testng.TestNG.runSuitesSequentially(TestNG.java:1197)
        at org.testng.TestNG.runSuitesLocally(TestNG.java:1122)
        at org.testng.TestNG.run(TestNG.java:1030)
        at com.sun.javatest.regtest.TestNGAction$TestNGRunner.main(TestNGAction. java:155)
        at com.sun.javatest.regtest.TestNGAction$TestNGRunner.main(TestNGAction. java:139)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at com.sun.javatest.regtest.MainWrapper$MainThread.run(MainWrapper.java: 94)
        at java.lang.Thread.run(Thread.java:744)

Comments
Release team: Approved for fixing
19-11-2013

Webrev: http://cr.openjdk.java.net/~sundar/8028161/
15-11-2013

- Rationale for why it must be fixed The fix is already in nashorn forest - need to go into jdk8/tl forest. When jtreg is used to run nashorn tests (instead of "ant test"), without this fix, a single test fails on certain platforms (solaris). - Risk Assessment None. This is test only change where jtreg mode to run test is changed ("othervm" specified in test tag) - Level of testing coverage jtreg on nashorn repo runs after the fix - Size of fix single line in a test source (where jtreg test tag is changed) The fix is already in nashorn repo of nashorn forest - it is better to get this into jdk8/tl and then to jdk8/master.
15-11-2013

Fix pushed to nashorn forest: changeset: 637:fea9f0f9bbde tag: tip user: sundar date: Thu Nov 14 15:53:49 2013 +0530 summary: 8028161: nashorn: src/jdk/nashorn/api/scripting/ScriptEngineTest.java
14-11-2013

To fix with othervm mode.
14-11-2013

After updating the sources and rebuilding everything is ok. There is however the issue of this test failing when running under samevm or agentvm mode with the failure noted below, adding the othervm tag will allow the test to work, if this test is run via jprt of nightly it is likely to fail as they run the tests in agentvm mode, I will leave it you to reopen this bug and fix this or open a new one. diff --git a/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java b/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java --- a/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java +++ b/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java @@ -50,7 +50,7 @@ * * @test * @build jdk.nashorn.api.scripting.Window jdk.nashorn.api.scripting.WindowEventHandler jdk.nashorn.api.scripting.VariableArityTestInterface jdk.nashorn.api.scripting.ScriptEngineTest - * @run testng jdk.nashorn.api.scripting.ScriptEngineTest + * @run testng/othervm jdk.nashorn.api.scripting.ScriptEngineTest */ public class ScriptEngineTest { test public void jdk.nashorn.api.scripting.ScriptEngineTest.scriptObjectAutoConversionTest() throws javax.script.ScriptException: failure java.lang.RuntimeException: java.lang.ClassNotFoundException: jdk.nashorn.api.scripting.Window.funcJSObject at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:382) at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:544) at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:526) at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:522) at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:193) at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264) at jdk.nashorn.api.scripting.ScriptEngineTest.scriptObjectAutoConversionTest(ScriptEngineTest.java:532) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80) at org.testng.internal.Invoker.invokeMethod(Invoker.java:715) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:907) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1237) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111) at org.testng.TestRunner.privateRun(TestRunner.java:767) at org.testng.TestRunner.run(TestRunner.java:617) at org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at org.testng.SuiteRunner.run(SuiteRunner.java:240) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:51) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:85) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1197) at org.testng.TestNG.runSuitesLocally(TestNG.java:1122) at org.testng.TestNG.run(TestNG.java:1030) at com.sun.javatest.regtest.TestNGAction$TestNGRunner.main(TestNGAction.java:155) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at com.sun.javatest.regtest.MainAction$SameVMRunnable.run(MainAction.java:728) at java.lang.Thread.run(Thread.java:744) Caused by: java.lang.ClassNotFoundException: jdk.nashorn.api.scripting.Window.funcJSObject at jdk.nashorn.internal.runtime.NativeJavaPackage.classNotFound(NativeJavaPackage.java:157) at jdk.nashorn.internal.scripts.Script$\^eval\_.runScript(<eval>:1) at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:498) at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:207) at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378) ... 34 more window.setTimeout: 100, code: foo()
13-11-2013

I checked by jdk8 b115 on Linux. Same issue is reproduced. That is because JDK-8027753 has not made into jdk8 b115. But if you build jdk8-tl forest and use that JDK to run nashorn jtreg tests, then all tests pass. So either you may want to wait for next JDK-8 snapshot that will have the fix or use jdk8-tl forest build to run nashorn jtreg tests.
13-11-2013

It is as if ScriptObject to JSObject conversion implemented by changeset: 634:dcedc753fd09 user: sundar date: Mon Nov 04 18:52:22 2013 +0530 summary: 8027753: Support ScriptObject to JSObject, ScriptObjectMirror, Map, Bindings auto-conversion as well as explicit wrap, unwrap is not there in the binary nashorn.jar at all -- but test alone has been updated!! i.e., somehow a stale nashorn.jar is used to run tests using new test sources. Without that scenario, I can explain the scenario reported. JDK under test per log is /net/scanas404.us.oracle.com/export/java-re/jdk/8/ea/b115/binaries/solaris-x64 Does the nashorn.jar in that binary includes in the above changeset? For example, javap -c on jdk.nashorn.internal.runtime.linker.NashornLinker class from the nashorn.jar (in that binary) would tell us if that is the case or not - we'd see JSObject conversion code.
13-11-2013