Given the following Java code, how can I use the IntelliJ or Eclipse debugger to return false
from the condition() method?
public boolean condition() {
return (4 == add());
}
public int add() {
return 2 + 2;
}
In most languages supported by Visual Studio, you can edit your code in the middle of a debugging session and continue debugging. To use this feature, click into your code with your cursor while paused in the debugger, make edits, and press F5, F10, or F11 to continue debugging.
Open Debug Configuration -> Debugger -> Enable Reverse Debugging at startup . Than you can press shift+F5 or shift+F6 for step back like F5 or F6 for step forward.
Sadly it is not possible to go back to a single line, the JVM does not support this.
In Eclipse you can use Force Return.
Just place a breakpoint on return (4 == add());
and type false
on the Display view-tab. Then make a selection of your false
, right click and hit "Force Return".
In IntelliJ (since IDEA 15 EAP) you can use Force return.
Extract from jetbrains' blog
You can force the return from the current method without executing any more instructions from it:
NB :
If the method returns a value, you’ll have to specify it (smart code completion provided).
If the method has try-finally blocks, you’ll be able to choose whether to execute them or not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With