hotswap-agent-intellij-plugin
hotswap-agent-intellij-plugin copied to clipboard
New classes not loaded
I am using open jdk 1.7 and the plugin works fine with modifying methods, new methods and new class fields. However, when I add a new class and then refer to it from an existing class, the new class doesn't get loaded. The IDE (Intellij) loads the existing class with the new modification referring to the new class, but it doesn't load the new class. This causes the app to crash and a restart is required.
If I got it right, by "loading new class" you actually mean "newly added classes doesn't instantiated that could lead to unexpected null references in related object instances". Actually DCVM and other similar stuff only allow to "swap" classes which then can be classloaded by particular classloader in JVM. But it doesn't affect current object instances. So in general you should bring program to the needed state manually: e.g. if you add some field in class which render dialog, you need to reopen dialog again just to let you program to instantiate a new field.
To simplify such process the Hoswap Agent itself provides some "plugins" to different technologies and frameworks (e.g. Spring support and other, see http://hotswapagent.org Framework Plugins). Such plugins can "restart" and "re-init" the application in some cases and you don't need to think how to do in manually.
What I meant is that once my application is up and running (Tomcat 7), if I add a new class to my project and I compile it, it doesn't get loaded into the JVM. Intellij will put out a message "0 classes loaded" or something similar.
I am just trying to figure out if this functionality is supported or not regardless of any framework.
--Thanks
Then you definitely should recheck http://hotswapagent.org/mydoc_plugin_tomcat.html and https://github.com/HotswapProjects/HotswapAgent first. How it works with particular version of Tomcat and if there is some conflicts with Tomcat custom classloaders or not. Maybe some additional configuration is needed in your case.
This IDEA plugin just start your Tomcat configuration with -XXaltjvm=dcevm -javaagent:hotswap-agent.jar JVM options. The actual swap performed in hotswap-agent.jar.