RFR(L): 8218628: Add detailed message to NullPointerException describing what is null.
christoph.langer at sap.com
Fri Feb 8 10:50:42 UTC 2019
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:
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".
> -----Original Message-----
> From: hotspot-runtime-dev <hotspot-runtime-dev-
> bounces at openjdk.java.net> On Behalf Of Lindenmaier, Goetz
> Sent: Donnerstag, 7. Februar 2019 17:43
> To: hotspot-runtime-dev at openjdk.java.net; Java Core Libs <core-libs-
> dev at openjdk.java.net>
> Subject: [CAUTION] RFR(L): 8218628: Add detailed message to
> NullPointerException describing what is null.
> 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.
> 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:
> I'm happy to incorporate your comments.
> Best regards,
More information about the core-libs-dev