Recently, there have been questions around some Javeleon specific code in the NetBeans source tree:
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!
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.
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:
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.
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 firstname.lastname@example.org.
I hope you're enjoying Javeleon. We'll certainly keep reloading!