Details

    • Subcomponent:
    • Introduced In Version:
    • Resolved In Build:
      b124
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        FULL PRODUCT VERSION :
        java version "1.8.0_72"
        Java(TM) SE Runtime Environment (build 1.8.0_72-b15)
        Java HotSpot(TM) 64-Bit Server VM (build 25.72-b15, mixed mode)


        ADDITIONAL OS VERSION INFORMATION :
        Darwin crab.lan 15.3.0 Darwin Kernel Version 15.3.0: Thu Dec 10 18:40:58 PST 2015; root:xnu-3248.30.4~1/RELEASE_X86_64 x86_64

        A DESCRIPTION OF THE PROBLEM :
        We've observed a change in behaviour between 1.8.0_71 and 1.8.0_72, where we now see a ReferenceError.

        Reproduction code is available.

        REGRESSION. Last worked in version 8u71

        ADDITIONAL REGRESSION INFORMATION:
        See https://github.com/makuk66/eval-script-repro, which runs code first with _71 which works, and then with _72, which doesn't.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Clone https://github.com/makuk66/eval-script-repro
        Edit run.sh to point to set the JAVA_HOME to point at your copies
        Execute ./run.sh
        Observe the output is per the README, demonstrating success for _71 and then failure for _72.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        I expected _72 to behave in the same way as _71
        ACTUAL -
        _72 gets a ReferenceError

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        Exception in thread "main" javax.script.ScriptException: ReferenceError: "logger" is not defined in <eval> at line number 1
            at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:467)
            at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:389)
            at jdk.nashorn.api.scripting.NashornScriptEngine.invokeMethod(NashornScriptEngine.java:199)
            at EvalScript.runTest(EvalScript.java:24)
            at EvalScript.main(EvalScript.java:12)
        Caused by: <eval>:1 ReferenceError: "logger" is not defined
            at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57)
            at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:319)
            at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:291)
            at jdk.nashorn.internal.objects.Global.__noSuchProperty__(Global.java:1428)
            at jdk.nashorn.internal.scripts.Script$Recompilation$1$15A$\^eval\_.L:1(<eval>:1)
            at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:625)
            at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
            at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
            at jdk.nashorn.internal.objects.NativeFunction.call(NativeFunction.java:192)
            at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:616)
            at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
            at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
            at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:199)
            at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:383)


        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        See https://github.com/makuk66/eval-script-repro/blob/master/EvalScript.java
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        I can change the sample code per https://github.com/makuk66/eval-script-repro/blob/master/EvalScript.java#L19 to make it work.

          Issue Links

            Activity

            Hide
            psonal Pallavi Sonal added a comment -
            Attached test case executed on :
            JDK 8u71 - Pass
            JDK 8u72 - Fail
            JDK 8u76 - Fail
            JDK 9ea b103 -Fail

            Show
            psonal Pallavi Sonal added a comment - Attached test case executed on : JDK 8u71 - Pass JDK 8u72 - Fail JDK 8u76 - Fail JDK 9ea b103 -Fail
            Hide
            hannesw Hannes Wallnoefer added a comment -
            This is caused by JDK-8138616 because the initial ScriptContext is no longer permanently associated with the Nashorn Global.

            The problem is that in the eval call with the ScriptContext argument a new Nashorn global is created. However, it is not permanently associated with the ScriptContext, so in the invokeMethod call we fall back to the engine's default context.

            I wonder if we shouldn't restore Global.initscontext (as its removal was not required to fix JDK-8138616). Another solution might be to set the Global.scontext thread-local when a Global is created for a ScriptContext on demand.
            Show
            hannesw Hannes Wallnoefer added a comment - This is caused by JDK-8138616 because the initial ScriptContext is no longer permanently associated with the Nashorn Global. The problem is that in the eval call with the ScriptContext argument a new Nashorn global is created. However, it is not permanently associated with the ScriptContext, so in the invokeMethod call we fall back to the engine's default context. I wonder if we shouldn't restore Global.initscontext (as its removal was not required to fix JDK-8138616 ). Another solution might be to set the Global.scontext thread-local when a Global is created for a ScriptContext on demand.
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/dev/nashorn/rev/8fd05a60a3b4
            User: hannesw
            Date: 2016-06-20 10:15:09 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/dev/nashorn/rev/8fd05a60a3b4 User: hannesw Date: 2016-06-20 10:15:09 +0000
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/jdk9/nashorn/rev/8fd05a60a3b4
            User: lana
            Date: 2016-06-22 19:52:48 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/nashorn/rev/8fd05a60a3b4 User: lana Date: 2016-06-22 19:52:48 +0000

              People

              • Assignee:
                hannesw Hannes Wallnoefer
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: