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

TokenType#toString returned null

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 8
    • 8
    • core-libs
    • b106
    • generic
    • generic

    Description

      FULL PRODUCT VERSION :


      ADDITIONAL OS VERSION INFORMATION :
      Linux uchida-CM6870 3.8.0-26-generic #38-Ubuntu SMP Mon Jun 17 21:43:33 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      I built in reference to this:
      https://wiki.openjdk.java.net/display/Nashorn/Building+Nashorn

      A DESCRIPTION OF THE PROBLEM :
      Nashorn's bug tracker is this here?

      I like Rhino Parer and AST. So I expect that Nashorn still use it.
      When I ran the code like this:
      ```
      var ir = Packages.jdk.nashorn.internal.ir;
      var runtime = Packages.jdk.nashorn.internal.runtime;
      var parser = Packages.jdk.nashorn.internal.parser;

      var context = runtime.Context.getContext();
      var source = new runtime.Source('test', function() {
        if (1) {
          print('hoge');
        } else {
          print(1 + 2);
        }
      }.toString());

      var node = new parser.Parser(context.getEnv(), source, new runtime.Context.ThrowErrorManager(), true).parse();
      var lexContext = new ir.LexicalContext();
      node.accept(lexContext, new ir.visitor.NodeVisitor(lexContext) {
        enterDefault: function(node) {
          print(node.tokenType()/*.toString()*/ + ': ' + node);
          return true;
        }
      });
      ```

      got error:
      ```
      $ ./build/linux-x86_64-normal-server-release/images/j2sdk-image/bin/jjs ~/tmp/visitor.js
      function: [<unknown>] function runScript()
      function: var _L1 = [<unknown>] function _L1();
      function: var _L1 = [<unknown>] function _L1()
      function: _L1
      {: [<unknown>] function _L1()
      {: if (1);
      if: if (1)
      Exception in thread " main " java.lang.NullPointerException
      at jdk.nashorn.internal.runtime.ConsString.<init>(ConsString.java:55)
      at jdk.nashorn.internal.runtime.ScriptRuntime.ADD(ScriptRuntime.java:547)
      at jdk.nashorn.internal.scripts.Script$visitor._L17(/home/uchida/tmp/visitor.js:18)
      at jdk.nashorn.internal.ir.visitor.NodeVisitor$$NashornJavaAdapter.enterDefault(Unknown Source)
      at jdk.nashorn.internal.ir.visitor.NodeVisitor.enterLiteralNode(NodeVisitor.java:478)
      at jdk.nashorn.internal.ir.visitor.NodeVisitor$$NashornJavaAdapter.enterLiteralNode(Unknown Source)
      at jdk.nashorn.internal.ir.LiteralNode.accept(LiteralNode.java:215)
      at jdk.nashorn.internal.ir.IfNode.accept(IfNode.java:78)
      at jdk.nashorn.internal.ir.Node.accept(Node.java:291)
      at jdk.nashorn.internal.ir.Block.accept(Block.java:139)
      at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:51)
      at jdk.nashorn.internal.ir.Block.accept(Block.java:344)
      at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:297)
      at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:51)
      at jdk.nashorn.internal.ir.LexicalContextExpression.accept(LexicalContextExpression.java:46)
      at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:49)
      at jdk.nashorn.internal.ir.VarNode.accept(VarNode.java:127)
      at jdk.nashorn.internal.ir.Node.accept(Node.java:291)
      at jdk.nashorn.internal.ir.Block.accept(Block.java:139)
      at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:51)
      at jdk.nashorn.internal.ir.Block.accept(Block.java:344)
      at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:297)
      at jdk.nashorn.internal.scripts.Script$visitor.runScript(/home/uchida/tmp/visitor.js:16)
      at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:518)
      at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:204)
      at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:366)
      at jdk.nashorn.tools.Shell.apply(Shell.java:386)
      at jdk.nashorn.tools.Shell.runScripts(Shell.java:315)
      at jdk.nashorn.tools.Shell.run(Shell.java:179)
      at jdk.nashorn.tools.Shell.main(Shell.java:143)
      at jdk.nashorn.tools.Shell.main(Shell.java:122)
      ```

      jdk.nashorn.internal.parser.TokenType#toString may returned null.



      REPRODUCIBILITY :
      This bug can be reproduced always.

      Attachments

        Activity

          People

            jlaskey Jim Laskey
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: