Avoid infamous change – restart – wait – check development lifecycle!

Wednesday, Jan 14, 2015 | 2 minute read | Updated at Thursday, Mar 6, 2025

Tags: Java
Avoid infamous change – restart – wait – check development lifecycle!

Stop waiting for build & deploy make code changes. Write code and refresh your browser!

Use DCEVM and add java fields, methods, classes and use them without restarting your application server, it ’s a modification of the HotSpot VM that allows unlimited class redefinition at run-time. You can add/remove fields and methods and change the super types of a class at run-time. The features of DCEVM are likely to be integrated in a future update of #Java 8 as part of JEP 159.

View code changes instantly and increases team velocity!

DCEVMJVM Hot Swap
Changes to method bodiesyesyes
Adding/removing Methodsyesno
Adding/removing constructorsyesno
Adding/removing fieldsyesno
Adding/removing classesyesno
Adding/removing annotationsyesno
Changing static field valueyesno
Adding/removing enum valuesyesno
Modifying interfacesyesno
Replacing superclassyesno
Adding/removing implemented interfacesnono
Initializes new instance fieldsyesno

You ’ll need to patch your own version of java (latest as of today is 1.7.71)

This project is similar to JRebel . Main differences are:

  • HotswapAgent (DCEVM) supports Java8!
  • HotswapAgent does not need any additional configuration for basic project setup.
  • JRebel is currently more mature and contains more plugins.
  • JRebel is neither open source nor free.
  • JRebel modifies bytecode of all classes on reload. You need special IDE plugin to fix debugging.
  • HotswapAgent extraClasspath is similar to JRebel configuration
  • HotswapAgent adds watchResources configuration

Patching Java to use DCEVM

Download from https://github.com/dcevm/dcevm/releases the right patch for java 1.7.71 it is https://github.com/dcevm/dcevm/releases/download/light-jdk7u71%2B2/installer-light-jdk7u71.2.jar

Run it as administrator, it will find your installed Java JDK or you can use “Add installation directory”

Click on both Replace by DCEVM and Install DCEVM as altjvm

Now add to all your launchers the following -XXaltjvm=dcevm

Reloading Spring Bean

Each application framework (Spring, Hibernate, Logback, ) needs special reloading mechanism to keep up-to-date after class redefinition (e.g. Hibernate configuration reload after new entity class is introduced). Hotswap agent works as a plugin system and ships preconfigured with all major framework plugins. It is easy to write your custom plugin even as part of your application.

Download agent.jar from https://github.com/HotswapProjects/HotswapAgent/releases

Save anywhere on disk, e.g. in C:\java\hotswap-agent.jar for example

add to all your launchers the following -javaagent:C:\java\hotswap-agent.jar

Spring plugin uses agent services to:

  • Modify root Spring classes to get Spring contexts and registered scan path
  • Watch for any resource change on a scan path
  • Watch for a hotswap of a class file within a scan path package
  • Reload bean definition after a change
  • and many other

References

Tags: Java

© 1997 - 2025 Cédric Walter blog

🌱 Powered by Hugo with theme Dream.

Others

If you like my work or find it helpful, please consider buying me a cup of coffee ☕️. It inspires me to create and maintain more projects in the future. 🦾

It is better to attach some information or leave a message so that I can record the donation 📝 , thank you very much 🙏.

Copyright information

All editorial content and graphics on our sites are protected by U.S. copyright, international treaties, and other applicable copyright laws and may not be copied without the express permission of Cedric Walter, which reserves all rights. Reuse of any of Cedric Walter editorial content and graphics for any purpose without The author ’s permission is strictly prohibited.

DO NOT copy or adapt the HTML or other code that this site creates to generate pages. It also is covered by copyright.

Reproduction without explicit permission is prohibited. All Rights Reserved. All photos remain copyright © their rightful owners. No copyright infringement is intended.

Disclaimer: The editor(s) reserve the right to edit any comments that are found to be abusive, offensive, contain profanity, serves as spam, is largely self-promotional, or displaying attempts to harbour irrelevant text links for any purpose.

About me

Cédric Walter is a French-Swiss software engineer based in Zurich, Switzerland. PGP: DF52 ADDA C81A 08A6