File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Reload a modified java class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Reload a modified java class " Watch "Reload a modified java class " New topic

Reload a modified java class

Manu Somasekhar
Ranch Hand

Joined: May 22, 2012
Posts: 44

I was doing some byte code injection with asm. I tried to inject some code to the class file. But it is found that if I tried to find the injected code, it is not available within the already loaded class. So a clean restart of JVM is required to find the injected code within the object.
So I was wondering how can I reload a class without restarting the JVM ?
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

Byte code injection and class loading aren't really beginning topics, so I'm going to move this thread.
Manu Somasekhar
Ranch Hand

Joined: May 22, 2012
Posts: 44
Thanks Paul.

Once again I am answering to my own question.

In order to achieve what I mentioned, one needs to extend ClassLoader and try to reload the classes when ever required.

I got the answer from here

I agree. Here's the link:
subject: Reload a modified java class
It's not a secret anymore!