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

coleen.phillimore at oracle.com coleen.phillimore at oracle.com
Tue Mar 5 00:55:43 UTC 2019

On 2/21/19 9:27 AM, Lindenmaier, Goetz wrote:
> Hi Andrew,
>> Ok. However, if you have the appropriate method bytecodes and the BCI at
>> which the exception occurred then I'm not sure why you would need ASM.
> I implemented it in C++ at first. I was asked to investigate an implementation
> in Java by the reviewers.

For the record, I think the C++ implementation is more straightforward 
than trying to use the Stackwalker and ASM because there's other code 
just like it right here. You have all the information you need directly 
in the Throwable.backtrace field. Walking it makes sense to me.  Also 
the StackWalker has a cost because it creates ResolvedMethodNames that 
must be interned in the native code in case of redefinition.

I didn't make it through the code for bytecodeUtils but I think it 
should be in the interpreter directory where all the other bytecode 
iterating methods are.  It does seem expensive when printing an NPE 
message.  I wonder if there's some easily helpful variable names that 
you could pick out and not have to do all this work for every sort of 
bytecode.  Also the file uses non hotspot names also like 
'createInvalidSource' that should be fixed.


There's a 'version' in the backtrace.  If the method->version() doesn't 
match the one in the backtrace, this should return false, because the 
method was redefined and the bci probably won't match. There's a bunch 
of code in javaClasses that does the similar thing.

This isn't a full review.


> Thanks!
>    Goetz
>> Also, it was not strictly correct when I said all that is retained is
>> the method bytecodes. Exception tables, line number tables and local var
>> name & type tables are also retained.
>> regards,
>> Andrew Dinn
>> -----------
>> Senior Principal Software Engineer
>> Red Hat UK Ltd
>> Registered in England and Wales under Company Registration No. 03798903
>> Directors: Michael Cunningham, Michael ("Mike") O'Neill, Eric Shander

More information about the hotspot-runtime-dev mailing list