Useful message about NullPointerException

pike pike630 at
Tue Jan 27 14:45:31 UTC 2015

kedar mhaswade wrote
> When the JVM executes instructions like getfield
> <>,
> getstatic, invokevirtual etc. with *objref* on the operand stack and if
> *objref* is null, an NPE is thrown. It appears that the JVM could tell us
> more about which *objref* was null at run-time. Candidate for an RFE?

Yes, agree with you on this. Actually the JVM has some information about
which reference is null when the NPE is thrown. It's reasonable if this kind
of information can be provided when NPE is thrown. This will save much time
for debugging.

kedar mhaswade wrote
> That aside, (and Chris's trick is nice), but if you have no access to the
> source for the offending code, life is hard in general, isn't it? Because
> if you can't have control over the source, making that source run on a
> platform where such an RFE would be perhaps fixed (a future release of the
> JDK) would be even harder, no? 

It's quite common that someone may have no access to the source code which
throws the NPE. For example, API developers may often not be able to access
user's source code, the only thing they can get are a bunch of logs.

View this message in context:
Sent from the OpenJDK Core Libraries mailing list archive at

More information about the core-libs-dev mailing list