www.wuerthinger.net Thomas has posted 2 posts at DZone. View Full User Profile

JavaOne 2010: Unlimited Hotswapping for Java

09.20.2010
| 10699 views |
  • submit to reddit

At this years JavaOne, we will present an open source project that aims at bringing unlimited hotswapping capabilities to the Java HotSpot(TM) virtual machine. Our modified version of the virtual machine is capable of adding and removing fields and methods of Java classes at runtime. Additionally, it is possible to change the super type (e.g., the set of implemented interfaces or the super class). There is no performance penalty or indirection introduced in contrast to existing bytecode rewriting techniques. You can use the VM without additional tools from within the debugger of your favorite Java IDE.

The enhanced virtual machine is freely available from http://ssw.jku.at/dcevm/. You can download an installer to patch an existing Java 6 or Java 7 installation. If you are interested in technical details about our approach, you are welcome to attend my JavaOne presentation on Wednesday, September 22, 13:00 at the Hilton San Francisco, Yosemite C. A recent version of the source code is also available from the MLVM wiki pages at http://wikis.sun.com/display/mlvm/HotSwap. The project is currently sponsored by Oracle and Guidewire.

0
Average: 5 (6 votes)
Published at DZone with permission of its author, Thomas Wuerthinger.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Jaran Nilsen replied on Tue, 2010/09/21 - 4:50am

Interesting project. Can you say anything about differences from JRebel? 

Thomas Wuerthinger replied on Tue, 2010/09/21 - 12:22pm in response to: Jaran Nilsen

Our solution comes without bytecode rewriting or class loading tricks, but modifies the virtual machine directly. Additionally, our VM is open source and free to use!

Alan Keefer replied on Tue, 2010/09/21 - 1:21pm

To expand on the differences with JRebel a bit further:  JRebel doesn't handle inheritance hierarchy changes, while the DCEVM does (you can change supertypes, implement new interfaces, etc.).  Because it's implemented within the VM rather than using classloader tricks, the DCEVM also doesn't impose any overhead on startup or during classloading, and doesn't affect stack traces or debuggers.

The DCEVM, however, won't automatically scan for class file changes like JRebel will:  it relies on being told what to swap, generally via interaction with an IDE, the same way that standard Java hotswapping is kicked off (since it is standard Java hotswapping).

Jaran Nilsen replied on Wed, 2010/09/22 - 1:17am in response to: Alan Keefer

Sounds interesting - will give it a try! 

Hemanta Sapkota replied on Thu, 2010/09/23 - 1:38am

Tried it and it works like a charm.!!

Kode Ninja replied on Thu, 2010/09/23 - 6:43am

In JRebel, through plugins, you can integrate 3rd party frameworks like Spring, Hibernate and application servers like Tomcat, WebSphere etc so that when hotswapping occurs, the framework-specific context can also be preserved. Taking a simple e.g., consider a web application running on Grails, where, when you edit/save a class, Grails hot deploys your changes, but your session is lost. So you need to relogin. But, with JRebel, I think even that can be avoided. So, can something like this be achieved with DCE also?

Peter Rexer replied on Fri, 2010/09/24 - 1:40pm in response to: Kode Ninja

AFAIK, DCE will keep the old version of the object in memory until it is ready to be GC'd. New instances of the class will get the new behavior.

Thomas Wuerthinger replied on Fri, 2010/09/24 - 11:57pm

All objects will be migrated to be instances of the new version of the class immediately during the class redefinition step. Fields will be copied if their name and type match. It is also possible to manually specify $transformer and $staticTransformer methods in case a more sophisticated state transfer is necessary. Currently we do not auto-generate such transformers for particular frameworks. As an example, we have a prototype that works with the NetBeans Mantisse GUI builder such that controls are relayouted automatically after redefining a JPanel class. I hope this answers your question.

Spentmoretime M... replied on Sun, 2010/09/26 - 10:07pm

This sounds very cool. I can see an immediate application for developers... Imagine being able to test your changes without deploying or restarting your JVM!

Tire Works replied on Thu, 2011/08/04 - 8:23am

Applying the patch, the JVM itself is capable of transforming a class definition (e.g. add or remove methods) without performance loss! Especially for dynamic languages, this would obviously be a blessing. -Tire Works

Kyle Thomas replied on Sun, 2011/10/09 - 4:49am

Whenever there is a change or configuration of a working system, hotswapping could be of use. The reason of using hotswapping is to have convenience during shut down of computers, it will avoid delay and nuisances. That's why there are many who use hot swapping. - Kyle Thomas Glasser

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.