What code changes are automatically reflected in eclipse in debug mode?
I use eclipse (to write, debug ) as an IDE. In debug mode when I make some changes,like initializing a local variable, they are refle开发者_如何学Pythoncted automatically.
But other changes like changing the value of a static variable; sometimes I get a message saying I need to restart the VM and sometimes I don't.
Now the question is what sort of changes are automatically reflected and what doesn't.
I use remote debugging, but will be there any difference when running the program from eclipse?
You're seeing Hotswap in action. It's limited to changing method bodies only. More info here.
It is not the IDE feature, but VM feature of remote debugging. VM now can handle simple changes in logic inside the methods of variable initializers, but can't treat with changed class structure.
The reloading is treated normally, when your class structure doesn't change: you don't remove or add members, methods or inner classes, because adding members or inner classes changes the size of allocated for the class memory. Methods doesn't change the memory size, but changes their structure.
Here you can find some explanations.
Static variables are class variables that are instantiated once the class. They are instantiated at class loading time. Changing static variables will therefore require the VM to reload and instantiated the changed static variable.
That's all I can provide for your question.
HotSwap is very limited, it can reload only simple method body changes.
Take a look at JRebel, it can reload other code changes as well (like adding/removing fields/methods/annotations/enum values, etc). See its detailed feature list.
(Please note that JRebel is a commercial product, with free licenses available for OSS and Scala developers.)
In remote debugging, hot code replacement isn't possible at all because eclipse can't swap class files inside a different JVM.
The remote debugger connects to a different virtual machine and monitors the code that is executed inside that remote machine. Just the source files are local.
精彩评论