I recently had a task where I had to use hot code replace functionality. So I did it using the Java Instrumentation API available in tools.jar.
Does eclipse use some different logic for hot replace of new class files or uses same Java API ? I tried to read from some places but was not clear:
Eclipse Java debugger transmits new class files over the debugging channel to another JVM
This line in Eclipse Hot Code Replace was not clear.
Hot code replace (HCR) is a debugging technique whereby the Eclipse Java debugger transmits new class files over the debugging channel to another JVM. In the case of Eclipse development, this also applies to the VM that runs the runtime workbench.
The “may be out of sync” warning indicates the change to a class within Eclipse has not been replaced in the server's JVM. To resolve this problem you must restart your server. In the near future we are planning to add an application RELOAD feature that we believe will workaround this problem.
Hot code replacement (HCR), which doesn't require a restart, is a fast debugging technique in which the Java debugger transmits new class files over the debugging channel to another JVM.
Hot code (or hot code path) are execution paths in your application / compiler in which most of the execution time is spent, and thus which are potentially executed very often.
I believe eclipse use the same logic, they are both relying on a native interface called JVMTI. The JVMTI provide tools to inspect the state, and to control the execution of applications running in the Java virtual machine.
There is a agent of JVMTI in the Java Instrumentation Implementation. The agent to talks to vm and perform certain tasks. it also has redefineClasses method.
Eclipse Java debugger or other tools use the JPDA (Java Platform Debugger Architecture), and the JPDA mainly have three parts (JVMTI,JDWP,JDI). JVMTI act as debuggee,JDI act as debugger,and the JDWP act as communication channel between them.
In the end, they all talk to JVMTI,and it use the same logic.
No, debuggers usually use JDI.
com.sun.jdi.VirtualMachine#redefineClasses
See the following link for details. http://docs.oracle.com/javase/7/docs/technotes/guides/jpda/index.html
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