Feature request: NullPointer with several objects in same source code line - easily spot the object being null

Josef Lehner privat-josef-lehner at gmx.de
Thu Feb 21 10:07:57 PST 2013

Dear Hotspot-Runtime team,

every once in a while every Java programmer encounters a 
NullPointerException and it is often hard to find out which object is 
null, especially in production where debugging isn't possible.

It would be fantastic if the jvm could blame the object causing the 

Thanks in advance.

Best regards


String s1=null;
String s2=null;
s1.concat(s2.toString()); // Line 7

Exception in thread "main" java.lang.NullPointerException <<< should be 
something like >Exception in thread "main" 
java.lang.NullPointerException: s2 is null<
     at stuff.Example.main(Example.java:7)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at java.lang.reflect.Method.invoke(Method.java:487)
     at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

More information about the hotspot-runtime-dev mailing list