Edit Java Class file at runtime
How it works #
The Dynamic Code Evolution Virtual Machine (DCE VM) is a modification of the Java HotSpot(TM) VM that allows unlimited redefinition of loaded classes at runtime. The current hotswapping mechanism of the HotSpot(TM) VM allows only changing method bodies. Our enhanced VM allows adding and removing fields and methods as well as changes to the super types of a class.
This is an open source project released under the GPL v2.0. You can download the source code as well as binaries for Windows, Mac, and Linux VMs.
This is work in progress. If you want to stay up-to-date and keep informed about the state of the project, you are welcome to sign up for the newsletter.
Hot deployment based on Java HotSwap #
With some IDEs you can perform changes on your java classes, compile them and test the results without redeploying the project or restarting your server. This approach is based in JVM HotSwap.
HotSwap allows debuggers to update class bytecode, using the same class identity. This meant that all objects could refer to an updated class and execute new code when their methods were called, preventing the need to reload a container whenever class bytecode was changed
Unfortunately, this redefinition is limited only to changing method bodies -- it cannot either add methods or fields or otherwise change anything else, except for the method bodies. Neither can you "hot deploy" JSPs and some other resources.
Solution 1
Hot deployment beyond HotSwap with JRebel #
To support the "hot deployment" of deeper changes in Java classes, you can use JRebel technology. JRebel installs a -javaagent that monitors the classes and resources in the workspace and propagates their changes to the running application. The following types of changes are supported:
- Changes to Java classes beyond what is supported by HotSwap (like method signatures).
- Changes to framework configuration (e.g. Spring XML files and annotations, Struts mappings, etc).
- Any changes to static resources (e.g. JSPs, HTMLs, CSSs, XMLs, .properties, etc
Here you can learn more about how Java HotSwap and JRebel work:
Solution 2
The Dynamic Code Evolution Virtual Machine (DCE VM) is a modification of the Java HotSpot(TM) VM that allows unlimited redefinition of loaded classes at runtime. The current hotswapping mechanism of the HotSpot(TM) VM allows only changing method bodies. Our enhanced VM allows adding and removing fields and methods as well as changes to the super types of a class.
This is an open source project released under the GPL v2.0. You can download the source code as well as binaries for Windows, Mac, and Linux VMs.
This is work in progress. If you want to stay up-to-date and keep informed about the state of the project, you are welcome to sign up for the newsletter.
Comments
Post a Comment