[JDK-8210527] NullPointerException in jstack exception rendering

Martin Buchholz martinrb at google.com
Tue Aug 20 02:35:37 UTC 2019


Thanks, Steven.
I updated the bug system to point to your patch and resolve yet another
duplicate I had reported earlier.
jdk-dev is surely not the right mailing list, but I'm not sure which is.

On Mon, Aug 19, 2019 at 1:11 PM Steven Schlansker <
stevenschlansker at gmail.com> wrote:

> Hello jdk-dev, (hopefully this is the best list, I did not see a
> jshell-dev)
>
> I spent most of my Friday diagnosing a confusing issue
> https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8229863
>
> which turned out to be a duplicate of JDK-8210527
> Unfortunately it's been open most of a year with no progress.
>
> The fix is seemingly trivial:
>
> diff -r 31b7274c7b9e src/jdk.jshell/share/classes/jdk/jshell/Eval.java
> --- a/src/jdk.jshell/share/classes/jdk/jshell/Eval.java Fri Aug 09
> 03:36:59 2019 +0200
> +++ b/src/jdk.jshell/share/classes/jdk/jshell/Eval.java Mon Aug 19
> 13:06:57 2019 -0700
> @@ -1106,7 +1106,7 @@
>                  Snippet sn = outer.wrapLineToSnippet(wln);
>                  String file = "#" + sn.id();
>                  elems[i] = new StackTraceElement(klass, method, file,
> line);
> -            } else if (r.getFileName().equals("<none>")) {
> +            } else if ("<none>".equals(r.getFileName())) {
>                  elems[i] = new StackTraceElement(r.getClassName(),
> r.getMethodName(), null, r.getLineNumber());
>              } else {
>                  elems[i] = r;
>
> I verified this fix against jdk13 tip.  Before:
>
> Unexpected exception reading startup: java.lang.NullPointerException
> 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.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.startUpRun(JShellTool.java:1143)
>         at
> jdk.jshell/jdk.internal.jshell.tool.JShellTool.resetState(JShellTool.java:1099)
>         at
> jdk.jshell/jdk.internal.jshell.tool.JShellTool.start(JShellTool.java:933)
>         at
> jdk.jshell/jdk.internal.jshell.tool.JShellToolBuilder.start(JShellToolBuilder.java:254)
>         at
> jdk.jshell/jdk.internal.jshell.tool.JShellToolProvider.run(JShellToolProvider.java:94)
>         at JshellNpe.main(JshellNpe.java:20)
>
> After,
>
> Exception java.lang.IllegalStateException: This helpful exception message
> is lost
>       at JshellNpe.lambda$2 (JshellNpe.java:27)
>       at $Proxy0.hashCode (Unknown Source)
>       at JshellNpe.init (JshellNpe.java:28)
>       at (#s1:1)
>
> Much better!
>
> What can I do to help move this issue forward to resolution?
>
> thanks,
> Steven
>
>


More information about the jdk-dev mailing list