Caching INFO's is problematic(but solvable) because of hot-deployment. I've been through this exercise a few times with JBoss AOP's caching of Javassist structures.
We should probably go back to a interface-based because of #4 as we me be lazy-loading typeinfo's with either reflect or javassist structures.
If they are cached against their associated classloader there should not be a problem.
By this I mean the ClassLoader of the Class not the application (thread context classloader).
WeakHashMap<ClassLoader, Map<className, WeakReference<ClassInfo>>
The WeakReference is only required if the ClassInfo contains references back
to the Class.
It could also be a SoftReference if you are prepared to put up with
recalculating this information if the GC discards it.
This won't work. I tried it. ClassLoaders never seem to be garbage collected. This may be the fault of JBoss AOP as the Advisor holds a reference to the class which holds a reference to the ClassLoader. The Advisor is a static field on the Class.
I also don't trust SoftReferences
If you have:
public class MyClass
public static Class myClass = MyClass.class; // or the same thing indirectly
The GC should detect this is no longer referenceable
when you lose all references to the ClassLoader.
The only thing that would stop it getting gced would be if the advisor
is held elsewhere, e.g. inside the AspectManager.
More likely, something else is holding a reference to
an instance of the class,
a subsidary object that holds a reference to the class (method, field, etc)
something holding a reference to another static constant of the class
that is not getting undeployed/dereferenced.
Yeah, I tried going the WeakReference route at one time and it just didn't work. I may not have found all the reference leaks.
So do you want I should refactor it into
interfaces and an
abstraction implementation == what you have now
or are you going to do this?
We can do the other stuff later.
Don't lose my javadoc if you do it :-)
i'm not getting to it for awhile. I'm going to do some aspects for the aspect library.
Don't forget I need the ClassAdapter api otherwise I'm going to get
stuck very soon in terms of what I can implement/test.
I'm already stuck on the XML deployer with Alex changing the parser api on me,
although I can test the metadata changes without an XML version.
Have you seen this thread?
The priority is supposed to be the framework the aspects plug into.
I'm doing the interface stuff.