[15] RFR: 8248476: No helpful NullPointerException message after calling fillInStackTrace

Lindenmaier, Goetz goetz.lindenmaier at sap.com
Wed Jul 15 08:27:54 UTC 2020


Hi Remi,

Thanks for looking at the change.

> the static final fields should be in uppercase to make the code 
> more readable,
Fixed.

> you need to use new String("1") because "1" may be a valid string, 
Why that? I only use the values in this code, they are private, and the
field is private.
They just need to be different from each other, and different from all
potential results of getExtendedNPEMessage().

> i also think
> that "1" and "2" are not explicit enough, using something like
> "MUST_COMPUTE_EXTENTED_NPE_MESSAGE" seems better IMO.
Changed. I thought a short string saves memory ...
 
> i don't think you need to declare extendedMessage volatile, it is only
> accessed inside a synchronized block on this.
Fixed.
 
> in getMessage, you can use a early return to simplify the code shape
>   synchronized(this) {
>     if (extendedMessage == mustComputeExtendedNPEMessage) {
>        // Only the original stack trace was filled in. Message will
>        // compute correctly.
>        return extendedMessage = getExtendedNPEMessage();   // <-- HERE
I need to check for NO_EXTENDED_MESSAGE before returning. 
Else I return "2" now "NO_EXTENDED_MESSAGE".

I made a new webrev, but it seems I need to follow webrev 06...
http://cr.openjdk.java.net/~goetz/wr20/8248476-NPE_fillInStackTrace-jdk15/07.2/

Best regards,
  Goetz.



More information about the hotspot-runtime-dev mailing list