Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse :Edit the source and continue debugging

I am using Eclipse IDE (Helios Version) While debugging in Eclipse , is it possible to edit the source and continue debugging ??

For example i have this file While debugging when i tried to modify the a4 value during debugging its not reflecting ??

public class Tes {

    public static void main(String args[]) {
        int a4 = 15;

        for (int i = 0; i < a4; i++) {
            System.out.println(i);
        }

    }
}
like image 636
Pawan Avatar asked Dec 08 '11 05:12

Pawan


1 Answers

Yes it is possible to edit the source and continue debugging in Eclipse! You'll find extensive information here: Debugging with the Eclipse Platform (scroll down to the section Hotswap Bug Fixing: On-the-fly code fixing).

If you are running Java Virtual Machine (JVM) V1.4 or higher, Eclipse supports a feature called Hotswap Bug Fixing (not available in JVM V1.3 or lower). It allows the changing of source code during a debugger session, which is better than exiting the application, changing the code, recompiling, then starting another debugging session. To use this function, simply change the code in the editor and resume debugging.

There are some cases where the feature will not work. E.g. if you make changes to your main method's a4 variable, the JVM will not be able to remove all stack frames running old code from the call stack. The debugger data will be lost.

To see the Hotswap Bug Fixing JVM feature in action, just move the code from your main method in the Test class to some other class. Here's what I mean:

Hotswap Bug Fixing in Action

Now you can modify the code on the fly while debugging in the MyObject class. Have fun!

EDIT: Just found a similar question at superuser.com: Debugging in Eclipse, how to run until a breakpoint

like image 118
nowaq Avatar answered Sep 28 '22 02:09

nowaq