Tutorial :Why can't I drag execution point in IntelliJ (I can in Visual Studio)



Question:

In Visual Studio, when debugging, one can drag the execution point (current instruction pointer, yellow dot) to another place in the current method.

This is impossible in IntelliJ, and some have stated it's generally impossible in Java. Why?


Solution:1

IntelliJ interacts with a running JVM through the standard Java debugging interface, so it can debug programs' against different JDKs. This does not support moving the execution point around as you describe.

It does let you wind the call stack back and perform a method call again. In IntelliJ, use the threads window to select a stack frame of a suspended thread and wind back to it. Then continue the thread to re-call the method at that point in the program.

Note: this will not roll back the state of the objects, so strange effects may occur.


Solution:2

In Eclipse, if you edit a method being debugged causing the debugged code to be updated the JVM rolls back execution to the first safe place. Usually this is the first line in that method.

It is very helpful in a debugging scenario.


Solution:3

You can tell the debugger to "Run to line" forward.


Solution:4

Java doesn't have a current execution pointer which can point to a random piece of code. Java assumes the order of execution is in the code, not something you would manipulate.

Perhaps you could explain why you would want to do this and we can let you know another way of achieving the same thing.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »