RFR(L): 8218628: Add detailed message to NullPointerException describing what is null.

Lindenmaier, Goetz goetz.lindenmaier at sap.com
Thu Feb 7 16:43:24 UTC 2019


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 mailing list