JavaRebel: Dynamic Classloading in the JVM
JavaRebel brings Ruby and PHP style dynamic reloading of classes to Java. While it currently has several limitations it can speed up development dramatically.
JavaRebel allows an application (stand-alone or within an application server) to reload most class changes on the fly, including adding and removing methods and fields.
Using bytecode modification and a little bit of magic JavaRebel extends the JVM with ability to reload almost arbitrary changes to classes on-the-fly. This includes adding and removing both methods and fields and the only forbidden changes are to ‘extends’ and ‘implements’ clauses. Since all the existing object instances are preserved the application and server can continue running and code changes are immediately visible in the application.
Some limitations that have been discovered include:
- getClass().getPackage() returns null. Zeroturnaround is aware of this and are working on resolving it
- Customer classloaders are not supported
- No hooks are currently provided for performing actions at resource reload (for instance refreshing an object in a dependency graph in a Spring application)
Despite the current limitations, feedback has been generally positive. Likewise, Zeroturnaround is working to make nightly builds available for use and plans to release an SDK soon to help solve some problems, such as the custom classloader restriction.
I have run into this problem before with instrumentation tools like emma and clover in the past (may have been fixed by now, not sure).
If this works well, I hope it leads to greater things being build into the JDK itself (without hosing the business model of course !).
Edmund Jorgensen Nov 27, 2014
Lisa Adkins and Michael Spayd Nov 27, 2014