In the follow method, how could I create a line breakpoint at a.toString()
to catch only NullPointerException at this line?
public static void m1(String b){
String a = null;
b.toString();
a.toString();
}
I need to achieve:
a.toString
, but only when a NullPointerException is about to occur. If there is no NullPointerException, will not break.I have tried
and
or both of them combined, but it didnt break at all.
How to fix this?
your approach seems fine, just adjust it a little bit: line breakpoint should not suspend at all, it acts as a marker:
NPE breakpoint then will be enabled only after the debugger reached the line. Unfortunately there's no way to disable NPE breakpoint after that (only if it is hit)