Flushing the cache Dynamically
I'm not sure if this is the right place for this or exactly how to phrase the question, so here goes.
Is it possible/there a way to flush the class dynamically?
What I want to do is load a class. Modify it using BCEL, compile it and then reset it back to the original class loaded. If that makes any sense. Is this doable or will I have to load the class each time?
Thanks.
[399 byte] By [
legsa] at [2007-10-2 5:44:18]

> reset it back to the original class loaded.
> Is this doable or will I have to load the class each time?
You want to replace the code of a class? This is called loading the class, so you don't "have to", you "get to" do it :-)
As Rene said, discard the class loader.
There may a way to redefine a class using java.lang.instrument.Instrumentation. Check out redefineClasses() there. Google for all of that. This is however not supported by all JDKs, meant for debugging, and has a number of constraints (see redefineClasses() javadoc). You probably shouldn't try to use it for anything production-like, only for debugging. It'll lead to tears, I tell you... The right way to redefine classes in a production environment is to discard the class loader.