|
Java Concepts
|
|
Written by rajesh
|
|
Wednesday, 28 May 2008 17:27 |
|
Until recently any change to the source code would require you to stop the application, compile the classes and start your application again. Javarebel claims to change all that – you do need to restart your application if some classes are changed. Is it really so good?
JavaRebel is a small JVM plugin (-javaagent) that will reload changes made to Java class files and thus increasing developers productivity and decreasing turnaround as for the changes to take effect no redeploy or restart to the container is needed.
Lets us see whether it is really useful as they claim it to be.You can use JavaRebel with your application by just adding the following to JVM command line (note that it is important that the JAR would be named “javarebel.jar”)
-noverify -javaagent:/path/to/javarebel.jar (note this works only for 1.5, for 1.4 and lower versions of java check JavaRebel site)
To start with I will list down some of the limitations of JavaRebel.
1) Instance Fields within already instantiated objects of the reloaded classes will be left un initialized. Instance fields will be initialized only when a new class instance is created.
2) Static fields will never get initialized.
3) Sometimes debugger will fail to set a breakpoint.
4) The “this” instance variable will be renamed to “that”, evaluations in debugger will not work.
5) Conditional breakpoints may fail because instance variables are accessed by the debuggers as this.variable, which has to become that.variable.
6) Extra lines in the stack trace.
7) Changed to the class hierarchy will not be reloaded.
Moreover, JavaRebel is not free – You have to pay for it and adjust with the limitations.
Considering these limitations, I would go for JVM’s built in HotSwap mechanism. Though HotSwap has other limitations:
Although JavaRebel is more tolerant to code changes, its limitations over do its benefits. Reloading classes with instance variable addition/ deletion is of no use because in the already instantiated objects, the instance variables will remain null, static variables will never get reinitialized. Hotswap at least does not do things if it cannot do it right. JavaRebel, will create issues in your application’s execution, on which you will waste your time debugging.
I hope that sun will improve the built in hot swap feature and add support for reloading classes with add/removed methods, constructors, fields , annotations and addition of new classes on a more better way.
|
|
Last Updated ( Thursday, 29 May 2008 02:48 )
|