How do I create a breakpoint at a specific place without there being any code after it

69 Views Asked by At

I am creating breakpoints to debug my java application , and am using netbeans 6.8 (if this is relevant).

Basically the problem I have is that when I set a breakpoint and debug the program will break before it executes the code at that line. So for example if I have the following.

public static void someMethod() {
 Object iWantToInspectThis = someOtherMethod();
 if(somethingThatIsFalseInThisCase == true)
 {
  doSomethingElse();
 }
}

So , I want to set a watch on iWantToInspectThis object and then break after it is set to the return value of someOtherMethod() so I can see what it is set to.

But if I set a breakpoint on that line then I will not see the result of this line being executed, and I cannot set the breakpoint later (inside the if statement) because then it will not be reached.

The only way I can manage to do this is to add a useless line like System.out.println("this is pointless"); after the call and break there instead which seems like a stupid way to have to do it.

How does everybody else deal with this?

1

There are 1 best solutions below

0
On BEST ANSWER

Put a break on that line, and use step into next line (F8 if i remember correctly) so the line executes, and then you can see the value by hovering the mouse into the variable, or using a watch.