Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8134503 support ES6 parsing in Nashorn
  3. JDK-8156619

Unimplemented ES6 features should result in clear Error being thrown

    Details

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

      Description

      Unimplemented features crash codegen or result in illegal bytecode.

      While ES6 constructs are parsed fine, certain constructs result in codegen crash or illegal bytecode being generated. We should throw proper Error that says something like "this ES6 feature is not implemented".

      Example:

      File: x.js

      var [a, b] = [3, 4];

      Output:

      Exception in thread "main" java.lang.AssertionError: Failed generating bytecode for x.js:1
      at jdk.nashorn.internal.codegen.CompilationPhase$BytecodeGenerationPhase.transform(jdk.scripting.nashorn@9-internal/CompilationPhase.java:436)
      at jdk.nashorn.internal.codegen.CompilationPhase.apply(jdk.scripting.nashorn@9-internal/CompilationPhase.java:630)
      at jdk.nashorn.internal.codegen.Compiler.compile(jdk.scripting.nashorn@9-internal/Compiler.java:656)
      at jdk.nashorn.internal.runtime.RecompilableScriptFunctionData.compileTypeSpecialization(jdk.scripting.nashorn@9-internal/RecompilableScriptFunctionData.java:717)
      at jdk.nashorn.internal.runtime.RecompilableScriptFunctionData.getBest(jdk.scripting.nashorn@9-internal/RecompilableScriptFunctionData.java:897)
      at jdk.nashorn.internal.runtime.ScriptFunctionData.getGeneric(jdk.scripting.nashorn@9-internal/ScriptFunctionData.java:401)
      at jdk.nashorn.internal.runtime.ScriptFunctionData.createGenericInvoker(jdk.scripting.nashorn@9-internal/ScriptFunctionData.java:299)
      at jdk.nashorn.internal.runtime.ScriptFunctionData.getGenericInvoker(jdk.scripting.nashorn@9-internal/ScriptFunctionData.java:293)
      at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(jdk.scripting.nashorn@9-internal/ScriptFunctionData.java:637)
      at jdk.nashorn.internal.runtime.ScriptFunction.invoke(jdk.scripting.nashorn@9-internal/ScriptFunction.java:513)
      at jdk.nashorn.internal.runtime.ScriptRuntime.apply(jdk.scripting.nashorn@9-internal/ScriptRuntime.java:471)
      at jdk.nashorn.tools.Shell.apply(jdk.scripting.nashorn@9-internal/Shell.java:519)
      at jdk.nashorn.tools.Shell.runScripts(jdk.scripting.nashorn@9-internal/Shell.java:448)
      at jdk.nashorn.tools.Shell.run(jdk.scripting.nashorn@9-internal/Shell.java:186)
      at jdk.nashorn.tools.jjs.Main.main(jdk.scripting.nashorn.shell@9-internal/Main.java:102)
      at jdk.nashorn.tools.jjs.Main.main(jdk.scripting.nashorn.shell@9-internal/Main.java:78)
      Caused by: java.lang.AssertionError: Unexpected node [{I%_1}a, {I%_2}b] in store epilogue
      at jdk.nashorn.internal.codegen.CodeGenerator$Store$2.enterDefault(jdk.scripting.nashorn@9-internal/CodeGenerator.java:4503)
      at jdk.nashorn.internal.ir.visitor.NodeVisitor.enterLiteralNode(jdk.scripting.nashorn@9-internal/NodeVisitor.java:567)
      at jdk.nashorn.internal.ir.LiteralNode$ArrayLiteralNode.accept(jdk.scripting.nashorn@9-internal/LiteralNode.java:928)
      at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(jdk.scripting.nashorn@9-internal/LexicalContextNode.java:57)
      at jdk.nashorn.internal.ir.LiteralNode$ArrayLiteralNode.accept(jdk.scripting.nashorn@9-internal/LiteralNode.java:923)
      at jdk.nashorn.internal.codegen.CodeGenerator$Store.epilogue(jdk.scripting.nashorn@9-internal/CodeGenerator.java:4500)
      at jdk.nashorn.internal.codegen.CodeGenerator$Store.store(jdk.scripting.nashorn@9-internal/CodeGenerator.java:4557)
      at jdk.nashorn.internal.codegen.CodeGenerator.loadASSIGN(jdk.scripting.nashorn@9-internal/CodeGenerator.java:3903)
      at jdk.nashorn.internal.codegen.CodeGenerator.access$900(jdk.scripting.nashorn@9-internal/CodeGenerator.java:178)
      at jdk.nashorn.internal.codegen.CodeGenerator$2.enterASSIGN(jdk.scripting.nashorn@9-internal/CodeGenerator.java:925)
      at jdk.nashorn.internal.ir.visitor.NodeOperatorVisitor.enterBinaryNode(jdk.scripting.nashorn@9-internal/NodeOperatorVisitor.java:113)
      at jdk.nashorn.internal.ir.BinaryNode.accept(jdk.scripting.nashorn@9-internal/BinaryNode.java:335)
      at jdk.nashorn.internal.codegen.CodeGenerator.loadExpression(jdk.scripting.nashorn@9-internal/CodeGenerator.java:863)
      at jdk.nashorn.internal.codegen.CodeGenerator.loadExpression(jdk.scripting.nashorn@9-internal/CodeGenerator.java:839)
      at jdk.nashorn.internal.codegen.CodeGenerator.loadExpressionAsType(jdk.scripting.nashorn@9-internal/CodeGenerator.java:835)
      at jdk.nashorn.internal.codegen.CodeGenerator$16.evaluate(jdk.scripting.nashorn@9-internal/CodeGenerator.java:3901)
      at jdk.nashorn.internal.codegen.CodeGenerator$Store.store(jdk.scripting.nashorn@9-internal/CodeGenerator.java:4555)
      at jdk.nashorn.internal.codegen.CodeGenerator.loadASSIGN(jdk.scripting.nashorn@9-internal/CodeGenerator.java:3903)
      at jdk.nashorn.internal.codegen.CodeGenerator.access$900(jdk.scripting.nashorn@9-internal/CodeGenerator.java:178)
      at jdk.nashorn.internal.codegen.CodeGenerator$2.enterASSIGN(jdk.scripting.nashorn@9-internal/CodeGenerator.java:925)
      at jdk.nashorn.internal.ir.visitor.NodeOperatorVisitor.enterBinaryNode(jdk.scripting.nashorn@9-internal/NodeOperatorVisitor.java:113)
      at jdk.nashorn.internal.ir.BinaryNode.accept(jdk.scripting.nashorn@9-internal/BinaryNode.java:335)
      at jdk.nashorn.internal.codegen.CodeGenerator.loadExpression(jdk.scripting.nashorn@9-internal/CodeGenerator.java:863)
      at jdk.nashorn.internal.codegen.CodeGenerator.loadExpression(jdk.scripting.nashorn@9-internal/CodeGenerator.java:839)
      at jdk.nashorn.internal.codegen.CodeGenerator.loadAndDiscard(jdk.scripting.nashorn@9-internal/CodeGenerator.java:3694)
      at jdk.nashorn.internal.codegen.CodeGenerator.enterExpressionStatement(jdk.scripting.nashorn@9-internal/CodeGenerator.java:1732)
      at jdk.nashorn.internal.ir.ExpressionStatement.accept(jdk.scripting.nashorn@9-internal/ExpressionStatement.java:63)
      at jdk.nashorn.internal.ir.Node.accept(jdk.scripting.nashorn@9-internal/Node.java:286)
      at jdk.nashorn.internal.ir.Block.accept(jdk.scripting.nashorn@9-internal/Block.java:229)
      at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(jdk.scripting.nashorn@9-internal/LexicalContextNode.java:57)
      at jdk.nashorn.internal.ir.Block.accept(jdk.scripting.nashorn@9-internal/Block.java:505)
      at jdk.nashorn.internal.ir.FunctionNode.accept(jdk.scripting.nashorn@9-internal/FunctionNode.java:394)
      at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(jdk.scripting.nashorn@9-internal/LexicalContextNode.java:57)
      at jdk.nashorn.internal.ir.LexicalContextExpression.accept(jdk.scripting.nashorn@9-internal/LexicalContextExpression.java:47)
      at jdk.nashorn.internal.ir.FunctionNode.accept(jdk.scripting.nashorn@9-internal/FunctionNode.java:56)
      at jdk.nashorn.internal.codegen.CompilationPhase.transformFunction(jdk.scripting.nashorn@9-internal/CompilationPhase.java:634)
      at jdk.nashorn.internal.codegen.CompilationPhase.access$100(jdk.scripting.nashorn@9-internal/CompilationPhase.java:55)
      at jdk.nashorn.internal.codegen.CompilationPhase$BytecodeGenerationPhase.transform(jdk.scripting.nashorn@9-internal/CompilationPhase.java:423)
      ... 15 more

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: