RFR: JDK-8234634: JShell could leverage the better NullPointerException analysis
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Wed Nov 27 13:18:19 UTC 2019
I like it very much - great work.
I get what you say about depending on XX options, but this is, I think,
a nice usability boost, and I'm not too picky about what we have to do
in order to get it :-)
Maurizio
On 22/11/2019 10:52, Jan Lahoda wrote:
> Hi,
>
> Maurizio suggested on core-libs-dev that JShell could leverage the
> better NullPointerException analysis. This patch tried to do it. The
> outcome for the user is e.g.:
> ---
> jshell> String s = null;
> s ==> null
>
> jshell> s.length()
> | Exception java.lang.NullPointerException: Cannot invoke
> "String.length()" because "s" is null
> | at (#2:1)
>
> jshell> String test(Object o) { return o.toString(); }
> | created method test(Object)
>
> jshell> test(null)
> | Exception java.lang.NullPointerException: Cannot invoke
> "Object.toString()" because "o" is null
> | at test (#3:1)
> | at (#4:1)
> ---
>
> There are three parts of this patch:
> 1. enabling -g:vars, so that the NPE analysis has more data to work on
> 2. enabling -XX:+ShowCodeDetailsInExceptionMessages, so that the
> enhanced analysis runs. It feels a little bit unfortunate to depend on
> a non-standard VM option, but this is only done in the tool (not in
> the engine), so it may be OK.
> 3. processing of the NPE message to strip references to the synthetic
> JShell classes.
>
> Webrev: http://cr.openjdk.java.net/~jlahoda/8234634/webrev.00/
> JBS: https://bugs.openjdk.java.net/browse/JDK-8234634
>
> How does this look?
>
> Thanks,
> Jan
More information about the kulla-dev
mailing list