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

Optimistic rewrite in object literal causes ArrayIndexOutOfBoundsException

    XMLWordPrintable

    Details

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

      Backports

        Description

        The following code throws ArrayIndexOutOfBoundsException with JDK9 with optimistic types enabled:

        var m = 1;

        var obj = {
            p0: m,
            p1: m = "foo",
            p2: m
        };

        Appearently the restof handle expects a second copy of the JD4 object being initialized on the stack which is not available in the RewriteException's stack array.

        The object literal code is generated by FieldObjectCreator, but SpillObjectCreator (used for object literals with >= 256 properties) exhibits the same problem.

        Output:
        Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
        at jdk.nashorn.internal.scripts.Script$Recompilation$2$JDK_8078049$cu1$restOf.:program(test/script/basic/JDK-8078049.js:0)
        at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:636)
        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)


          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  Created:
                  Updated:
                  Resolved: