You have to load a modified class if you want
to see the effects. There is no way to directly
modify a class in the JVM memory.
Thank you for your reply! Is the same true with BCEL library as well? Is that a fundamental JVM restriction?
So, theoretically speaking, if the app runs from a CD-ROM or some other read-only store, you'd have to save the class to an in-memory ByteArrayOutputStream and load it? I don't know much about this. Is that something that's done all the time to achieve on the fly modification?
Tapestry does a lot of Javassist-based class enhancement. It leaves the original class alone and creates a subclass. Often the starting class is abstract, and Tapestry uses Javassist to fill in the abstract methods.
Javassist allows you to create and configure a CtClass instance and then use that to create a java.lang.Class you can instantiate.
If you want to do something more aspect-like, you can do a lot of juggling of class loaders to ensure that Javassist has a chance to enhance the bytecodes before they are converted into a java.lang.Class; I believe the tutorial discusses how to fit Javassist into the pipeline (but this wasn't something I needed for my work, so I haven't investigated it).
Ah, I think I understand. Thank you for your reply!