Hi Goetz,

thanks for bringing this into OpenJDK finally. I know of people that'll be 
quite happy about this feature.

I had a quick glance through the code. Here are a few findings:

src/java.base/share/classes/java/lang/NullPointerException.java:
line 56:
remove a space before the comment

line 62:     private transient boolean lazyComputeDefaultMessage;
I think the name for this variable is not well chosen. I'd prefer 
lazyComputeMessage, because it's not a default message, it's rather "the" 
message of the exception.
Then, I think you should initialize the field right away in this line to true, 
no need to do it in the constructor. (Or can't that be done for transient 
fields?? 😊)

122     private native void setDefaultMessage(String extendedMessage);
Here, I agree with David, that you should do it in Java. Just use a shared 
secret, then you don't even need reflection...
It also should not be "setDefaultMessage" but rather "setMessage".

Best regards
Christoph

 
> -----Original Message-----
> From: hotspot-runtime-dev <hotspot-runtime-dev-
> boun...@openjdk.java.net> On Behalf Of Lindenmaier, Goetz
> Sent: Donnerstag, 7. Februar 2019 17:43
> To: hotspot-runtime-...@openjdk.java.net; Java Core Libs <core-libs-
> d...@openjdk.java.net>
> Subject: [CAUTION] RFR(L): 8218628: Add detailed message to
> NullPointerException describing what is null.
> 
> Hi,
> 
> since Java 5, our internal VM reports verbose null pointer exception
> messages. I would like to contribute this feature to OpenJDK.
> 
> With this change, messages as
>    "java.lang.NullPointerException: while trying to load from a null int array
> loaded from local variable 'ia1'"
> are printed.  For more examples see the JBS bug or the test included.
> https://bugs.openjdk.java.net/browse/JDK-8218628
> 
> The messages are generated by parsing the bytecodes. For not to have any
> overhead when the
> NPE is allocated, the message is only generated when it is accessed by
> getMessage() or
> serialization. For this I added a field to NPE to indicate that the message 
> still
> needs to be
> computed lazily.
> 
> Please review:
> http://cr.openjdk.java.net/~goetz/wr19/8218628-exMsg-NPE/01/
> I'm happy to incorporate your comments.
> 
> Best regards,
>   Goetz
> 

Reply via email to