- Loading...
The class data structures of the Java HotSpot virtual machine are immutable during the execution of a program. While new classes can be loaded, it is not possible to change existing classes (e.g. add/remove methods or fields). This projects tries to relax this condition to allow arbitrary changes to existing Java classes (including changes to the class hierarchy) while running a Java program.
Latest patch update: February 2, 2010
Patch name: hotswap.patch
Please send any comments or questions to: wuerthinger@ssw.jku.at
Initial implementation description (April 1, 2009): Thomas Wuerthinger, Dynamic Code Evolution for the Java HotSpotVirtual Machine
Type of Change |
Supported? |
Possible problems after resume |
---|---|---|
Swap Method Body |
yes |
|
Add Method |
yes |
|
Remove Method |
yes |
NoSuchMethodError |
Add Field |
yes |
|
Remove Field |
yes |
NoSuchFieldError |
Add Supertype |
yes |
|
Remove Supertype |
yes |
possible VM crash |
Classes can implement a method "void $mutator()".
This method is called on every object whose class was redefined and can therefore be used to initialize the new instances of a class.
Example code:
Initial version class A { int x; } |
New version class A' { int x; int doubleX; void $mutator() { doubleX = 2 * x; } } |