8

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

Sometimes, though, it will not -- in which case it pops up a message, or says "(may be out of sync)" next to the threads in the Debug pane.

What determines the kind of changes that can be hot-swapped? I've noticed these changes usually fail:

  • introducing new anonymous inner classes
  • changing classes (renaming/adding/removing fields and methods) when the class is instantiated
  • adding a try-catch block

but sometimes it seems to be almost random. What is the logic behind determining whether code can be replaced or not?

1 Answer 1

9

Method statements (procedural code) work. Everything related to adding, removing or changing class schemas does not work. So no modifying inheritances, fields, extracting methods, changing signatures etc.

Usually hot-swapping method statements does not work if you are doing anything forbidden at the same time. Then the hot-swapping connection is "broken", so to say.

One thing I do not know for sure is anonymous classes. Have never tried that in connection with hot-swapping.

Edit: The guys over there at zeroturnaround have compiled a list in their features section what the jvm debugger can not do out of the box to promote their product: http://www.zeroturnaround.com/jrebel/features/ . Whether you like the tool or not, the list reflects my experience.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.