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

jshell needs to handle StackTraceElements with null filenames

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • None
    • tools
    • None

      (As reported by my colleague Michael Diamond)

      When jshell prints out a stacktrace, it needs to take missing filenames into account, else it will get NullPointerException in jdk.jshell.Eval.translateExceptionStack, causing jshell itself to terminate.

      # Recipe:
      $ (cat fail/Fail.java; javac -d . -g:none fail/Fail.java; jshell --class-path .)
      package fail;
      public class Fail {
        static { int x = 1 / 0; }
      }
      | Welcome to JShell -- Version 14-ea
      | For an introduction type: /help intro

      jshell> Class.forName("fail.Fail");
      Exception in thread "main" java.lang.NullPointerException
              at jdk.jshell/jdk.jshell.Eval.translateExceptionStack(Eval.java:1109)
              at jdk.jshell/jdk.jshell.Eval.asEvalException(Eval.java:907)
              at jdk.jshell/jdk.jshell.Eval.asJShellException(Eval.java:924)
              at jdk.jshell/jdk.jshell.Eval.asEvalException(Eval.java:908)
              at jdk.jshell/jdk.jshell.Eval.declare(Eval.java:888)
              at jdk.jshell/jdk.jshell.Eval.eval(Eval.java:140)
              at jdk.jshell/jdk.jshell.JShell.eval(JShell.java:493)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processSource(JShellTool.java:3558)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processSourceCatchingReset(JShellTool.java:1305)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processInput(JShellTool.java:1203)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.run(JShellTool.java:1176)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.start(JShellTool.java:975)
              at jdk.jshell/jdk.internal.jshell.tool.JShellToolBuilder.start(JShellToolBuilder.java:254)
              at jdk.jshell/jdk.internal.jshell.tool.JShellToolProvider.main(JShellToolProvider.java:120)

      (jshell died ...)

            rfield Robert Field (Inactive)
            martin Martin Buchholz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: