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

NullPointerException at jdk.nashorn.internal.codegen.LocalVariableTypesCalculator.symbolIsUsed(LocalVariableTypesCalculator.java:224)

    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:
      b33
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        I found this while trying Biwascheme ( https://github.com/biwascheme/biwascheme ) on nashorn jdk9-dev tip changeset: 1026:9f8ab1b79632

        jjs $biwascheme/release/biwascheme-0.6.2.js

        Exception in thread "main" java.lang.NullPointerException
        at jdk.nashorn.internal.codegen.LocalVariableTypesCalculator$LvarType.access$100(LocalVariableTypesCalculator.java:119)
        at jdk.nashorn.internal.codegen.LocalVariableTypesCalculator.symbolIsUsed(LocalVariableTypesCalculator.java:224)
        at jdk.nashorn.internal.codegen.LocalVariableTypesCalculator.symbolIsUsed(LocalVariableTypesCalculator.java:1473)
        at jdk.nashorn.internal.codegen.LocalVariableTypesCalculator.enterIdentNode(LocalVariableTypesCalculator.java:618)
        at jdk.nashorn.internal.ir.IdentNode.accept(IdentNode.java:136)
        at jdk.nashorn.internal.codegen.LocalVariableTypesCalculator.enterReturnNode(LocalVariableTypesCalculator.java:692)
        at jdk.nashorn.internal.ir.ReturnNode.accept(ReturnNode.java:91)
        at jdk.nashorn.internal.ir.Node.accept(Node.java:249)
        at jdk.nashorn.internal.ir.Block.accept(Block.java:152)
        at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:57)
        at jdk.nashorn.internal.ir.Block.accept(Block.java:399)
        at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:376)
        at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:57)
        at jdk.nashorn.internal.ir.LexicalContextExpression.accept(LexicalContextExpression.java:46)
        at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:58)
        at jdk.nashorn.internal.codegen.LocalVariableTypesCalculator$1.leaveFunctionNode(LocalVariableTypesCalculator.java:1238)
        at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:376)
        at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:57)
        at jdk.nashorn.internal.ir.LexicalContextExpression.accept(LexicalContextExpression.java:46)
        at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:58)
        at jdk.nashorn.internal.ir.PropertyNode.accept(PropertyNode.java:88)
        at jdk.nashorn.internal.ir.Node.accept(Node.java:249)
        at jdk.nashorn.internal.ir.ObjectNode.accept(ObjectNode.java:64)
        at jdk.nashorn.internal.ir.Node.accept(Node.java:249)
        at jdk.nashorn.internal.ir.CallNode.accept(CallNode.java:178)
        at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:57)
        at jdk.nashorn.internal.ir.LexicalContextExpression.accept(LexicalContextExpression.java:46)
        at jdk.nashorn.internal.ir.CallNode.accept(CallNode.java:41)
        at jdk.nashorn.internal.ir.BinaryNode.accept(BinaryNode.java:341)
        at jdk.nashorn.internal.ir.BinaryNode.accept(BinaryNode.java:341)
        at jdk.nashorn.internal.ir.ExpressionStatement.accept(ExpressionStatement.java:62)
        at jdk.nashorn.internal.ir.Node.accept(Node.java:249)
        at jdk.nashorn.internal.ir.Block.accept(Block.java:152)
        at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:57)
        at jdk.nashorn.internal.ir.Block.accept(Block.java:399)
        at jdk.nashorn.internal.ir.SplitNode.accept(SplitNode.java:94)
        at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:57)
        at jdk.nashorn.internal.ir.LexicalContextStatement.accept(LexicalContextStatement.java:53)
        at jdk.nashorn.internal.ir.SplitNode.accept(SplitNode.java:41)
        at jdk.nashorn.internal.ir.Node.accept(Node.java:249)
        at jdk.nashorn.internal.ir.Block.accept(Block.java:152)
        at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:57)
        at jdk.nashorn.internal.ir.Block.accept(Block.java:399)
        at jdk.nashorn.internal.codegen.LocalVariableTypesCalculator.leaveFunctionNode(LocalVariableTypesCalculator.java:1294)
        at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:376)
        at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:57)
        at jdk.nashorn.internal.ir.LexicalContextExpression.accept(LexicalContextExpression.java:46)
        at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:58)
        at jdk.nashorn.internal.codegen.CompilationPhase$9.transform(CompilationPhase.java:279)
        at jdk.nashorn.internal.codegen.CompilationPhase.apply(CompilationPhase.java:703)
        at jdk.nashorn.internal.codegen.Compiler.compile(Compiler.java:560)
        at jdk.nashorn.internal.runtime.Context.compile(Context.java:1159)
        at jdk.nashorn.internal.runtime.Context.compileScript(Context.java:1098)
        at jdk.nashorn.internal.runtime.Context.compileScript(Context.java:543)
        at jdk.nashorn.tools.Shell.runScripts(Shell.java:317)
        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)

        Based on some println debugging, I think I managed to reduce this to simple script below:

        function func(x, y) {
          while(true) {
             switch (y[0]) {
               case "bar":
                   x = 'xxx';
                   break;
             }
          }
          return x;
        }

        If you turn on asserts with -J-ea, we get the following trace:

        Exception in thread "main" java.lang.AssertionError
        at jdk.nashorn.internal.codegen.LocalVariableTypesCalculator.getLocalVariableType(LocalVariableTypesCalculator.java:998)
        at jdk.nashorn.internal.codegen.LocalVariableTypesCalculator.symbolIsUsed(LocalVariableTypesCalculator.java:1473)
        at jdk.nashorn.internal.codegen.LocalVariableTypesCalculator.enterIdentNode(LocalVariableTypesCalculator.java:618)
        at jdk.nashorn.internal.ir.IdentNode.accept(IdentNode.java:136)
        at jdk.nashorn.internal.codegen.LocalVariableTypesCalculator.enterReturnNode(LocalVariableTypesCalculator.java:692)
        at jdk.nashorn.internal.ir.ReturnNode.accept(ReturnNode.java:91)
        at jdk.nashorn.internal.ir.Node.accept(Node.java:249)
        at jdk.nashorn.internal.ir.Block.accept(Block.java:152)
        at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:57)
        at jdk.nashorn.internal.ir.Block.accept(Block.java:399)
        at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:376)
        at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:57)
        at jdk.nashorn.internal.ir.LexicalContextExpression.accept(LexicalContextExpression.java:46)
        at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:58)
        at jdk.nashorn.internal.codegen.LocalVariableTypesCalculator$1.leaveFunctionNode(LocalVariableTypesCalculator.java:1238)
        at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:376)
        at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:57)
        at jdk.nashorn.internal.ir.LexicalContextExpression.accept(LexicalContextExpression.java:46)
        at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:58)
        at jdk.nashorn.internal.ir.VarNode.accept(VarNode.java:171)
        at jdk.nashorn.internal.ir.Node.accept(Node.java:249)
        at jdk.nashorn.internal.ir.Block.accept(Block.java:152)
        at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:57)
        at jdk.nashorn.internal.ir.Block.accept(Block.java:399)
        at jdk.nashorn.internal.codegen.LocalVariableTypesCalculator.leaveFunctionNode
        [... more frames...]

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                attila Attila Szegedi
                Reporter:
                sundar Sundararajan Athijegannathan
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: