I'm the primary inventor of the Javeleon class reloading technology. Currently, I'm holding a post.doc. position at the University of Southern Denmark where I continue my research on dynamic software updating. I've spoken at JavaOne in 2009 and again in 2011. Allan has posted 12 posts at DZone. You can read more from them at their website. View Full User Profile

About Javeleon's Special Hooks in the NetBeans Platform

06.22.2012
| 2884 views |
  • submit to reddit

Recently, there have been questions around some Javeleon specific code in the NetBeans source tree:

http://hg.netbeans.org/main-golden/file/963b40ce3181/o.n.bootstrap/src/org/netbeans/JaveleonModule.java

and:

http://hg.netbeans.org/main-golden/file/963b40ce3181/o.n.bootstrap/src/org/netbeans/StandardModule.java#l624

The above indicates that Javeleon has special hooks in the NetBeans Platform code. But not many know why this code is there and what it really does.

So here is the story behind the small piece of Javeleon-code that ended up in the NetBeans Platform!

Introduction

Before we get to the code some introduction is probably required. First of all, Javeleon uses classloaders to accomplish the task of class reloading. Basically, Javeleon replaces the class loader of a NetBeans module to allow new code to be loaded.

The inner workings of Javeleon then handles the state transfer between the old and the new module, as well as all of the assignability issues between differently versioned classes and objects that pop up because of this setup. Hence, Javeleon needs to know which class loaders should be marked as updateable, meaning that each class loaded by that particular class loader object is reloadable.

StandardModule & JaveleonModule

This brings us to the one-liner within the constructor of StandardModule$OneModuleClassLoader that simply registers the class loader object for a module. This will allow Javeleon to replace particular class loaders when specific modules are reloaded. Because Javeleon will bring multiple versions of class loaders in play within the running application, we need to keep track of the currently active class loaders, which is why the JaveleonModule class was introduced.

JaveleonModuleClassLoader

In order for any of this to take effect we have also introduced the JaveleonModuleClassLoader class that piggy backs on the standard module reloading mechanism in NetBeans IDE also known as the “Reload in target platform” feature. The class can be viewed here:

http://hg.netbeans.org/main-golden/file/963b40ce3181/core.startup/src/org/netbeans/core/startup/JaveleonModuleReloader.java

This class utilizes the mentioned hooks in o.n.bootstrap to actually perform module reloading. What happens is that whenever the "Reload in target platform" is invoked a check is performed to see if Javeleon is present in the running system. If not, normal module reloading is performed. Otherwise, JaveleonModuleReloader kicks in and creates a new class loader, also modifying the NetBeans system class loader to enable loading of the most up-to-date classes in the module system. Also as seen in the JaveleonModuleReloader class, the meta-data as defined by annotations that end up within the layer.xml file is reflected right into the running application, making developing with Javeleon a truly live experience.

Recent Changes

Before NetBeans 7.0 came out Javeleon relied on runtime binary patching of the said NetBeans Platform classes to inject the Javeleon functionality at load time. This solution worked well, but everytime the core NetBeans developers changed something that our patch-code relied on, we had to make a new version-specific patch. But since 7.0 we have been fortunate to have built-in support for Javeleon module reloading directly within the NetBeans Platform code tree.

For that, we send our gratitiute to the NetBeans team and especially Jesse Glick and Jaroslav Tulach who made it all possible.

Now you can enjoy real module reloading with Javeleon. If you haven't already tried Javeleon with you NetBeans Platform application, please do so and let us know about the outcome. We are always ready to step in helping people to get set up and in case of issues we usually fix those on a day to day basis.

We're currently running out of bugs, so we need more bug-reports to keep us busy making Javeleon for the NetBeans Platform even more stable.

Also, success stories where you've been using Javeleon for a project, wheather it is a commercial product, an OSS project or a personal hobby project always keep us motivated to do even better. So please, send any comments, bug-reports and/or your story with Javeleon to support@javeleon.org.

I hope you're enjoying Javeleon. We'll certainly keep reloading!

Published at DZone with permission of its author, Allan Gregersen.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Emilian Bold replied on Fri, 2012/06/22 - 3:44am

Thanks for your article. I knew you needed that code to manage classloaders more easily and I found it interesting.

If you think about it, that code also provides hooks for any library that wants to instrument classloaders (if you ignore some hardcoded stuff).

Matt Coleman replied on Fri, 2012/10/19 - 1:33am in response to: Emilian Bold

I agree Emilian!!!javeloeon hooks are essential to  classloaders

present for graphic designer 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.