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.

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 :)

Educational Content

Bindings, Platforms, and Innovation

This presentation focuses on the Internet and separating myth from fact, history from the future, and the mundane from the imaginative. Bob Frankston presents a vision of what could and should be.

Orchestrating Long Running Activities with JBoss / JBPM

This article explores the use of JBoss and jBPM to implement design solutions that effectively address the issue of orchestrating long running activities.

Neo4j - The Benefits of Graph Databases

This presentation covers the use of graph databases as an optimal solution for data that is difficult to fit in static tables, rapidly evolving data or data that has a lot of optional attributes.

Realistic about Risk: Software development with Real Options

This session introduces Real Options and shows how it can help in running your project. Real Options is a decision-making process that can be used to manage risk.

Communication Flexibility Using Bindings

This article discusses the use of bindings on services and references (including the instance of non-configured bindings) as the means to implement SCA communications in a Web and SOA environment.

Writing DSLs in Groovy

After a short introduction to DSLs, Scott Davis plays with the keyboard showing how to approach the creation of a DSL by typing working snippets of Groovy code that get executed.

Scaling Agile with C/ALM (Collaborative Application Lifecycle Management)

IBM Rational and InfoQ present, Scaling Agile with C/ALM, an eBook showing organizations how to become “finely tuned software delivery machines” by enabling team integration and scaling.

Concurrent Programming with Microsoft F#

Amanda Laucher presents a real life enterprise application written in F#. She shows actual code snippets, explaining design decisions and suggesting how to use some of the F# constructs.