diff options
author | acolyer <acolyer> | 2005-11-19 17:08:48 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-11-19 17:08:48 +0000 |
commit | 522911ec81aeb3ec5b600939d3a2ee6e6297fd0c (patch) | |
tree | 311498b219cf1905e36eb022efedbcfdff785651 /weaver5 | |
parent | 99504bc120db0049fb441bb69b0f37a4a4f29cd9 (diff) | |
download | aspectj-522911ec81aeb3ec5b600939d3a2ee6e6297fd0c.tar.gz aspectj-522911ec81aeb3ec5b600939d3a2ee6e6297fd0c.zip |
tests and fix for pr116229 and pr116755. Also adds support and tests for parseTypePattern in PointcutParser.
Diffstat (limited to 'weaver5')
-rw-r--r-- | weaver5/java5-src/org/aspectj/weaver/reflect/Java15AnnotationFinder.java | 14 | ||||
-rw-r--r-- | weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java | 16 |
2 files changed, 22 insertions, 8 deletions
diff --git a/weaver5/java5-src/org/aspectj/weaver/reflect/Java15AnnotationFinder.java b/weaver5/java5-src/org/aspectj/weaver/reflect/Java15AnnotationFinder.java index 31abe3056..31de59c62 100644 --- a/weaver5/java5-src/org/aspectj/weaver/reflect/Java15AnnotationFinder.java +++ b/weaver5/java5-src/org/aspectj/weaver/reflect/Java15AnnotationFinder.java @@ -35,9 +35,15 @@ import org.aspectj.weaver.World; public class Java15AnnotationFinder implements AnnotationFinder { private Repository bcelRepository; + private ClassLoader classLoader; + // must have no-arg constructor for reflective construction public Java15AnnotationFinder() { - this.bcelRepository = new ClassLoaderRepository(getClass().getClassLoader()); + } + + public void setClassLoader(ClassLoader aLoader) { + this.bcelRepository = new ClassLoaderRepository(aLoader); + this.classLoader = aLoader; } /* (non-Javadoc) @@ -45,7 +51,7 @@ public class Java15AnnotationFinder implements AnnotationFinder { */ public Object getAnnotation(ResolvedType annotationType, Object onObject) { try { - Class annotationClass = Class.forName(annotationType.getName()); + Class annotationClass = Class.forName(annotationType.getName(),false,classLoader); if (onObject.getClass().isAnnotationPresent(annotationClass)) { return onObject.getClass().getAnnotation(annotationClass); } @@ -57,7 +63,7 @@ public class Java15AnnotationFinder implements AnnotationFinder { public Object getAnnotationFromClass(ResolvedType annotationType, Class aClass) { try { - Class annotationClass = Class.forName(annotationType.getName()); + Class annotationClass = Class.forName(annotationType.getName(),false,classLoader); if (aClass.isAnnotationPresent(annotationClass)) { return aClass.getAnnotation(annotationClass); } @@ -71,7 +77,7 @@ public class Java15AnnotationFinder implements AnnotationFinder { if (!(aMember instanceof AccessibleObject)) return null; AccessibleObject ao = (AccessibleObject) aMember; try { - Class annotationClass = Class.forName(annotationType.getName()); + Class annotationClass = Class.forName(annotationType.getName(),false,classLoader); if (ao.isAnnotationPresent(annotationClass)) { return ao.getAnnotation(annotationClass); } diff --git a/weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java b/weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java index c1e2d357a..c1f3c9fd4 100644 --- a/weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java +++ b/weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java @@ -57,14 +57,17 @@ public class Java15ReflectionBasedReferenceTypeDelegate extends private ResolvedType superclass; private ResolvedType[] superInterfaces; private String genericSignature = null; - private Java15AnnotationFinder annotationFinder = new Java15AnnotationFinder(); + private Java15AnnotationFinder annotationFinder = null; public Java15ReflectionBasedReferenceTypeDelegate() {} - public void initialize(ReferenceType aType, Class aClass, World aWorld) { - super.initialize(aType, aClass, aWorld); + @Override + public void initialize(ReferenceType aType, Class aClass, ClassLoader classLoader, World aWorld) { + super.initialize(aType, aClass, classLoader, aWorld); myType = AjTypeSystem.getAjType(aClass); + annotationFinder = new Java15AnnotationFinder(); + annotationFinder.setClassLoader(classLoader); } @@ -169,6 +172,7 @@ public class Java15ReflectionBasedReferenceTypeDelegate extends fromTypes(forMethod.getGenericExceptionTypes()), forMethod ); + ret.setAnnotationFinder(this.annotationFinder); return ret; } @@ -183,11 +187,13 @@ public class Java15ReflectionBasedReferenceTypeDelegate extends fromTypes(forConstructor.getGenericExceptionTypes()), forConstructor ); + ret.setAnnotationFinder(this.annotationFinder); return ret; } private ResolvedMember createGenericFieldMember(Field forField) { - return new ReflectionBasedResolvedMemberImpl( + ReflectionBasedResolvedMemberImpl ret = + new ReflectionBasedResolvedMemberImpl( org.aspectj.weaver.Member.FIELD, getResolvedTypeX(), forField.getModifiers(), @@ -195,6 +201,8 @@ public class Java15ReflectionBasedReferenceTypeDelegate extends forField.getName(), new UnresolvedType[0], forField); + ret.setAnnotationFinder(this.annotationFinder); + return ret; } public ResolvedMember[] getDeclaredPointcuts() { |