Debunking JavaRebel Myths
November 20th, 2007 by Jevgeni Kabanov
As JavaRebel matures and gets more and more into the spotlight we get the same arguments against it repeated again and again. It seems that it is hard for the skeptics out there to believe that we and not “insert your any huge company here” came up with such a useful and long needed invention. We decided to spread some light on the most outrageous claims out there.
Myth nr. 1: JavaRebel doesn’t do anything
Usually formulated as “JavaRebel just runs redeploy when classes are changed. My container already does that!” or even “It just compiles classes in a loop, a 3 line Perl script would do better!”.
The answer is simple: JavaRebel reloads compiled classes without redeploying the application. By reloading we mean that whatever changes you did to the code are instantly visible in your application. This is subject to some constraints (extends and implements changes cannot be propagated this way), but there is definitely no redeploying happening behind the curtain. All object instances are preserved, which means that your application just continues running. And as far as we know there are no comparable tools out there at the moment.
Myth nr. 2: JavaRebel just uses hotswapping/class redefinition
Nope. In fact although JavaRebel uses the “-javaagent” it does not use hotswapping for any of the reloaded classes. What’s more JavaRebel works fine on Java 1.4 where no hotswapping is available without tapping through JNI. It is not a simple hack/wrapper on top of hotswapping and uses an approach that would work even if there would not be any hotswapping in Java at all.
Myth nr. 3: Container/Framework/Application X already does this
Perhaps. There is a well-know approach for reloading “managed” classes that we have even documented some time ago. However it only works when the object graph can be completely reconstructed — for example it is serializable. This works for some classes in some frameworks (e.g. RIFE, Tapestry 5), but it is only limited to that. JavaRebel works on all classes, all objects, always. You don’t need to worry, which code are you changing, it will always get reloaded.











