InfoQ

News

JavaRebel: Dynamic Classloading in the JVM

Posted by Rob Thornton on Oct 26, 2007 07:00 AM

Community
Java
Topics
Artifacts & Tools

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.

5 comments

Reply

Typo by Jevgeni Kabanov Posted Oct 26, 2007 7:37 AM
Re: Typo by Michael Neale Posted Oct 26, 2007 7:54 AM
Re: Typo by Jevgeni Kabanov Posted Oct 26, 2007 8:24 AM
Re: Typo by Michael Neale Posted Oct 26, 2007 9:18 PM
Re: Typo by Jevgeni Kabanov Posted Oct 27, 2007 4:04 AM
  1. Back to top

    Typo

    Oct 26, 2007 7:37 AM by Jevgeni Kabanov

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

  2. Back to top

    Re: Typo

    Oct 26, 2007 7:54 AM 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.

  3. Back to top

    Re: Typo

    Oct 26, 2007 8:24 AM 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: http://www.zeroturnaround.com/forum/topic.php?id=16&replies=2.

  4. Back to top

    Re: Typo

    Oct 26, 2007 9:18 PM 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 !).

  5. Back to top

    Re: Typo

    Oct 27, 2007 4:04 AM 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? Definitely :)

Exclusive Content

Agile Project Management: Lessons Learned at Google

In this presentation filmed during QCon 2007, Jeff Sutherland, the creator of Scrum, talks about his visit at Google to do an analysis of Google's first implementation of Scrum.

AtomServer – The Power of Publishing for Data Distribution

In this article, Bryon Jacob and Chris Berry introduce AtomServer, their implementation of a full-fledged Atom Store based on Apache Abdera, which is now available as open source.

An Introduction to Virtualization

It is easy to think that virtualization applies only to servers. In reality the recent resurgence of the concept is also being applied to networking, storage, and application infrastructure.

REST Anti-Patterns

In this article, Stefan Tilkov explains some of the most common anti-patterns found in applications that claim to follow a "RESTful" design and suggests ways to avoid them.

Choosing between Routing and Orchestration in an ESB

In this article, Adrien Louis and Marc Dutoo discuss the differences and relative merits of using orchestration vs. routing in a typical ESB setup, and discuss various implementation options.

Enterprise Batch Processing with Spring

Wayne Lund discusses batch processing, Spring Batch objectives and features, scenarios for usage, Spring Batch architecture, scaling, example code, failures and retrying, and the future roadmap.

User Story Estimation Techniques

Developer Jay Fields draws on his experiences as a ThoughtWorks consultant to describe effective user story estimation techniques.

Security (CAS and OpenID) with Ruby

In this talk from QCon SF 2007, Justin Gehtland explains two open solutions to distributed identity and their Rails integration components: OpenID (using ruby-openid) and CAS (using rubycas-client).