Here is what I found about this issue:
1- there is a name for this on-the-fly change, it is called Class Reloading in Java
2- By default, Class Reloading is not supported by Java. However, you may use Java Platform Debugger Architecture (JPDA) to reload a class.
3- Javassist has a class for this, it's called HotSwapper
4- Another way to reload a class in runtime is to use a different ClassLoader instance. However, it is almost impossible to do this if your application is running in a Java Application Server or Web Server. You can simply mess with your server's internal ClassLoader.
By the way, the main reason for doing this was that I would like to be able to turn on/off logging and auditing of my Web application by method injection without needing to restart the server.
If any one knows a different approach, I will really appreciate if you could it share it.