import java.lang.ref.Reference;
import java.lang.ref.SoftReference;
import java.net.URL;
+import java.net.URLClassLoader;
import java.util.HashMap;
import java.util.Map;
import java.util.WeakHashMap;
*
* @see org.aspectj.apache.bcel.Repository
*
- * @version $Id: ClassLoaderRepository.java,v 1.6 2006/08/08 11:26:28 aclement Exp $
+ * @version $Id: ClassLoaderRepository.java,v 1.7 2006/08/18 14:51:00 acolyer Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
* @author David Dixon-Peugh
*/
public class ClassLoaderRepository implements Repository {
+ private static java.lang.ClassLoader bootClassLoader = null;
private java.lang.ClassLoader loader;
private WeakHashMap /*<String classname,JavaClass>*/loadedClassesLocalCache = new WeakHashMap();
private static Map /*<URL,JavaClass>*/loadedUrlsSharedCache = new HashMap();
}
public ClassLoaderRepository( java.lang.ClassLoader loader ) {
- this.loader = loader;
+ this.loader = (loader != null) ? loader : getBootClassLoader();
+ }
+
+ private static synchronized java.lang.ClassLoader getBootClassLoader() {
+ if (bootClassLoader == null) {
+ bootClassLoader = new URLClassLoader(new URL[0]);
+ }
+ return bootClassLoader;
}
/**
import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
import java.util.Collection;
import java.util.Collections;
*/
public class ReflectionBasedReferenceTypeDelegate implements ReferenceTypeDelegate {
+ private static final ClassLoader BootClassLoader = new URLClassLoader(new URL[0]);
+
protected Class myClass = null;
protected ClassLoader classLoader = null;
private World world;
this.myClass = aClass;
this.resolvedType = aType;
this.world = aWorld;
- this.classLoader = aClassLoader;
+ this.classLoader = (aClassLoader != null) ? aClassLoader : BootClassLoader;
}
protected Class getBaseClass() {
myType = AjTypeSystem.getAjType(aClass);
annotationFinder = new Java15AnnotationFinder();
argNameFinder = annotationFinder;
- annotationFinder.setClassLoader(classLoader);
+ annotationFinder.setClassLoader(this.classLoader);
this.typeConverter = new JavaLangTypeToResolvedTypeConverter(aWorld);
}