Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8059938

NPE restoring cached script with optimistic types disabled

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b35
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        A NullPointerException occurs when installing scripts from persistent cache with optimistic types disabled. When running the script below twice:

        $ java -jar dist/nashorn.jar --optimistic-types=false -pcc ./test/script/basic/JDK-8048079_2a.js
        parsed and compiled ok prototype.js
        $ java -jar dist/nashorn.jar --optimistic-types=false -pcc ./test/script/basic/JDK-8048079_2a.js
        Exception in thread "main" java.lang.NullPointerException
        at jdk.nashorn.internal.runtime.Context.install(Context.java:1249)
        at jdk.nashorn.internal.runtime.Context.compile(Context.java:1192)
        at jdk.nashorn.internal.runtime.Context.compileScript(Context.java:1123)
        at jdk.nashorn.internal.runtime.Context.evaluateSource(Context.java:1089)
        at jdk.nashorn.internal.runtime.Context.load(Context.java:773)
        at jdk.nashorn.internal.objects.Global.load(Global.java:1000)
        at jdk.nashorn.internal.scripts.Script$JDK_8048079_2a.:program(./test/script/basic/JDK-8048079_2a.js:34)
        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)

        Obviously a function in the constants array may not have an initializer when lazy compilation is enabled, so we need to add a null check right there.

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                hannesw Hannes Wallnoefer
                Reporter:
                hannesw Hannes Wallnoefer
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: