Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does eclipse use Java Instrumentation API for Hot Code replace

Tags:

java

eclipse

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.

like image 803
Narendra Pathai Avatar asked Jan 19 '13 12:01

Narendra Pathai


People also ask

What is hot code replace in eclipse?

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.

How do I fix hot code replace failed in eclipse?

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.

What is hot code replacement?

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.

What is Hot code?

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.


2 Answers

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.

like image 67
snow8261 Avatar answered Oct 19 '22 11:10

snow8261


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

like image 33
jdb Avatar answered Oct 19 '22 11:10

jdb