Hi Christoph, thanks for looking at this.
> src/java.base/share/classes/java/lang/NullPointerException.java: > line 56: > remove a space before the comment fixed. > 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. OK, removed 'default' > 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?? 😊) No, it must be initialized to false because there is a second constructor that uses a custom message (that was also the reason for the 'default' in the field name, it only applies to the constructor without custom message) > 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". Obviously, the problem is that the field is private. I see various ways to implement this. Please give advice: * reflection * shared secret * Add package visible "void setMessage (String msg)" to throwable. Best regards, Goetz. > > 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 > >