In the Eclipse debugger, what changes can be replaced by "hot code" with a running JVM?

In Eclipse, if you run the program under "Debug", you can make changes to the code, and most of the time it takes effect immediately.

Sometimes, however, it will not - in this case, it displays a message or says "(may not be synchronized)" next to the threads in the Debug panel.

What determines the type of change that can be hot-swappable? I noticed that these changes usually fail:

  • introducing new anonymous inner classes
  • changing classes (renaming / adding / deleting fields and methods) when creating an instance of a class
  • add try-catch block

but sometimes it seems almost random. What is the logic for determining if code can be replaced or not?

+8
java debugging eclipse jvm
source share
1 answer

Method statements (procedural code) work. Everything related to adding, removing or changing class schemes does not work. Thus, no inheritance changes, fields, extraction methods, signature changes, etc.

Typically, hot swap instructions do not work if you are doing something forbidden at the same time. Then the hot-swap connection is β€œbroken”, so to speak.

One thing that I don’t know for sure is anonymous classes. Never tried this due to hot swap.

Edit: the guys there at zeroturnaround put together a list in their functions section, which the jvm debugger cannot do out of the box to promote its product: http://www.zeroturnaround.com/jrebel/features/ . If you like this tool or not, the list reflects my experience.

+9
source share

All Articles