0

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.

Community
  • 1
  • 1
Vipin
  • 4,851
  • 3
  • 35
  • 65
  • 1
    You are talking about hot-swapping of code. But if you stop-start the server that is no issue. Your terminology is quite non-specific so I don't know what you're really referring to when you say "bouce the server". I can assume you made a typo and meant "bounce" and then I still don't know what it is. – Gimby May 16 '14 at 14:05
  • if you bounce the server, this is no problem at all. – Frederic Close May 16 '14 at 14:05
  • @Gimby, some people use it to describe restarting a server – epoch May 16 '14 at 14:11
  • @Gimby I have corrected typo. I am trying to search ducumentation where i read some limitation of this hot-swapping. – Vipin May 16 '14 at 14:16
  • @Vipin yes but you are not going to hot-swap. You are going to stop, replace the class and then start the server/runtime. Hot-swapping refers to replacing code into an active runtime without ever shutting it down, like you would commonly do when you are doing development. – Gimby May 16 '14 at 14:21
  • @Gimby probably this is answer to my question , if I restart server i should not worry about it. – Vipin May 16 '14 at 14:28
  • Exactly. At best your application is going to crash and burn because you should have updated two classes, not only one. – Gimby May 16 '14 at 14:32
  • 1
    Unrelated node: also consider to work on jar level, not class level (compile and replace jars instead of single classes) – Puce May 16 '14 at 14:36

1 Answers1

0

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.

Vipin
  • 4,851
  • 3
  • 35
  • 65