import org.aspectj.weaver.SourceContextImpl;
import org.aspectj.weaver.TypeVariable;
import org.aspectj.weaver.UnresolvedType;
+import org.aspectj.weaver.WeakClassLoaderReference;
import org.aspectj.weaver.WeaverStateInfo;
import org.aspectj.weaver.World;
import org.aspectj.weaver.patterns.PerClause;
*/
public class ReflectionBasedReferenceTypeDelegate implements ReferenceTypeDelegate {
- private static final ClassLoader BootClassLoader = new URLClassLoader(new URL[0]);
+ private static final ClassLoader BootClassLoader = new URLClassLoader(new URL[0]);// ReflectionBasedReferenceTypeDelegate.class.getClassLoader();
protected Class myClass = null;
- protected ClassLoader classLoader = null;
+ protected WeakClassLoaderReference classLoaderReference = null;
private World world;
private ReferenceType resolvedType;
private ResolvedMember[] fields = null;
this.myClass = aClass;
this.resolvedType = aType;
this.world = aWorld;
- this.classLoader = (aClassLoader != null) ? aClassLoader : BootClassLoader;
+ this.classLoaderReference = new WeakClassLoaderReference((aClassLoader != null) ? aClassLoader : BootClassLoader);
}
protected Class getBaseClass() {
import org.aspectj.weaver.ResolvedType;
import org.aspectj.weaver.ResolvedTypeMunger;
import org.aspectj.weaver.UnresolvedType;
+import org.aspectj.weaver.WeakClassLoaderReference;
import org.aspectj.weaver.World;
import org.aspectj.weaver.AjAttribute.AdviceAttribute;
import org.aspectj.weaver.patterns.Pointcut;
*/
public class ReflectionWorld extends World implements IReflectionWorld {
- private ClassLoader classLoader;
+ private WeakClassLoaderReference classLoaderReference;
private AnnotationFinder annotationFinder;
private ReflectionWorld() {
super();
this.setMessageHandler(new ExceptionBasedMessageHandler());
setBehaveInJava5Way(LangUtil.is15VMOrGreater());
- this.classLoader = ReflectionWorld.class.getClassLoader();
- this.annotationFinder = makeAnnotationFinderIfAny(classLoader, this);
+ this.classLoaderReference = new WeakClassLoaderReference(ReflectionWorld.class.getClassLoader());
+ this.annotationFinder = makeAnnotationFinderIfAny(classLoaderReference.getClassLoader(), this);
}
public ReflectionWorld(ClassLoader aClassLoader) {
super();
this.setMessageHandler(new ExceptionBasedMessageHandler());
setBehaveInJava5Way(LangUtil.is15VMOrGreater());
- this.classLoader = aClassLoader;
- this.annotationFinder = makeAnnotationFinderIfAny(classLoader, this);
+ this.classLoaderReference = new WeakClassLoaderReference(aClassLoader);
+ this.annotationFinder = makeAnnotationFinderIfAny(classLoaderReference.getClassLoader(), this);
}
public static AnnotationFinder makeAnnotationFinderIfAny(ClassLoader loader, World world) {
}
public ClassLoader getClassLoader() {
- return this.classLoader;
+ return this.classLoaderReference.getClassLoader();
}
public AnnotationFinder getAnnotationFinder() {
* @see org.aspectj.weaver.World#resolveDelegate(org.aspectj.weaver.ReferenceType)
*/
protected ReferenceTypeDelegate resolveDelegate(ReferenceType ty) {
- return ReflectionBasedReferenceTypeDelegateFactory.createDelegate(ty, this, this.classLoader);
+ return ReflectionBasedReferenceTypeDelegateFactory.createDelegate(ty, this, this.classLoaderReference.getClassLoader());
}
/* (non-Javadoc)