BT
x Your opinion matters! Please fill in the InfoQ Survey about your reading habits!

JavaRebel: Dynamic Classloading in the JVM

by Rob Thornton on Oct 26, 2007 |

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.

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Typo by Jevgeni Kabanov

Should be "custom", not "customer" classloaders :)

Re: Typo by Michael Neale

Yeah and at that it is a bit of a show stopper. There is so much meta programming going on these days (eg if you use hibernate, spring) behind the scenes that "custom" classloaders are the norm.

Re: Typo by Jevgeni Kabanov

JavaRebel supports custom classloaders themselves. JBoss, Spring, Hibernate, Tapestry 4 & 5 all run wonderfully. All these are used to create proxies or subclasses or just postprocess loaded classes. The thing that isn't supported is when you have classes in some custom places and use your own classloader to locate them. The issue is described here: www.zeroturnaround.com/forum/topic.php?id=16....

Re: Typo by Michael Neale

OK thats great ! What about dirty hackers (like me) who do tend to do the latter a bit ;) (don't try this at home kids !) - anything in the works like that?

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 !).

Re: Typo by Jevgeni Kabanov

OK thats great ! What about dirty hackers (like me) who do tend to do the latter a bit ;) (don't try this at home kids !) - anything in the works like that?<blockqoute></blockqoute>

Definitely :)

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

5 Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT