Search code examples
javatomcat.class-file

can we put hotifx( without build just move class file ) after adding new method in java class


My JAVA Application is running since last 10 days.

Now I want to put a .class file as bug fix in which I have introduced a new method , I dont want to do build. I will just put it as hotfix in classes directory and bounce the server.

Long back I read somewhere if we introdue new class / new method we can not put hotfix. If it is true I am looking for documentation for this.

Edit: When I searched using Term Hot-Swapping found some interesting links http://java.dzone.com/articles/reloading-java-classes-401 Limitations with Java Hotswap

Seems Hot-Swapping is limited to method bodies only , we have JVM Bug for this.

Edit2: Hot Swapping is not really required here , as I am restarting server.


Solution

  • I created a folder named classes and added it in classpath before respective jar file. Added .class file in classes folder according to its package structure and restarted server. Because class loader loads class file in the sequence we provide in classpath , my class from classes folder gets loaded and my changes are reflected at runtime.

    Like if my java file is com.vipin.test.Test.java , I i placed Test.class in classes/com/vipin/test folder.