Debugger: hot code replace- can not get it to work

here is a sample code

public class Test {
    public static void main(String[] args) throws Exception {
        do {
            System.out.println(1);
            Thread.sleep(1000);
        } while (true);

    }
}


I stop at first line, then replace

with

System.out.println(2);

make hot code replace (recompile), Idea says, 1 class was reloaded, then I run it again (f9)...

The result
1) Change is not taken into effect (it prints 1)
2) Breakpoint does not work anymore... it does not stop.

Win 7 x64, Java 6
Any ideas?

1 comment
Comment actions Permalink

HotSpot limitation - it can't replace a method being executed.
Just extract println() call into separate method and it'll be able to update it.

0

Please sign in to leave a comment.