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

Error in codegen for element access on primitive value

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8
    • None
    • core-libs
    • None
    • b82
    • Verified

      The following script:

      (1)[0]

      throws this:

      Exception in thread "main" java.lang.AssertionError: int is not compatible with object
      at jdk.nashorn.internal.codegen.MethodEmitter.popType(MethodEmitter.java:231)
      at jdk.nashorn.internal.codegen.MethodEmitter.dynamicGetIndex(MethodEmitter.java:1873)
      at jdk.nashorn.internal.codegen.CodeGenerator$1.enter(CodeGenerator.java:347)
      at jdk.nashorn.internal.ir.IndexNode.accept(IndexNode.java:95)
      at jdk.nashorn.internal.codegen.CodeGenerator.load(CodeGenerator.java:324)
      at jdk.nashorn.internal.codegen.CodeGenerator.load(CodeGenerator.java:305)
      at jdk.nashorn.internal.codegen.CodeGenerator$8.evaluate(CodeGenerator.java:2409)
      at jdk.nashorn.internal.codegen.CodeGenerator$Store.store(CodeGenerator.java:3199)
      at jdk.nashorn.internal.codegen.CodeGenerator.enterASSIGN(CodeGenerator.java:2411)
      at jdk.nashorn.internal.ir.visitor.NodeOperatorVisitor.enter(NodeOperatorVisitor.java:129)
      at jdk.nashorn.internal.ir.BinaryNode.accept(BinaryNode.java:176)
      at jdk.nashorn.internal.codegen.CodeGenerator$1.enterDefault(CodeGenerator.java:353)
      at jdk.nashorn.internal.ir.visitor.NodeVisitor.enter(NodeVisitor.java:197)
      at jdk.nashorn.internal.ir.BinaryNode.accept(BinaryNode.java:176)
      at jdk.nashorn.internal.codegen.CodeGenerator.load(CodeGenerator.java:324)
      at jdk.nashorn.internal.codegen.CodeGenerator.load(CodeGenerator.java:305)
      at jdk.nashorn.internal.codegen.CodeGenerator.enterDISCARD(CodeGenerator.java:2260)
      at jdk.nashorn.internal.ir.visitor.NodeOperatorVisitor.enter(NodeOperatorVisitor.java:67)
      at jdk.nashorn.internal.ir.UnaryNode.accept(UnaryNode.java:145)
      at jdk.nashorn.internal.codegen.CodeGenerator.enter(CodeGenerator.java:767)
      at jdk.nashorn.internal.ir.ExecuteNode.accept(ExecuteNode.java:80)
      at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:309)
      at jdk.nashorn.internal.codegen.Compiler.compile(Compiler.java:377)
      at jdk.nashorn.internal.runtime.Context.compile(Context.java:827)
      at jdk.nashorn.internal.runtime.Context.compile(Context.java:807)
      at jdk.nashorn.internal.runtime.Context.eval(Context.java:500)
      at jdk.nashorn.tools.Shell.readEvalPrint(Shell.java:375)
      at jdk.nashorn.tools.Shell.run(Shell.java:160)
      at jdk.nashorn.tools.Shell.main(Shell.java:136)
      at jdk.nashorn.tools.Shell.main(Shell.java:115)

      This should compile and run (see ES 11.2.1 Property Accessors)

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

              Created:
              Updated:
              Resolved: