From 7026369f6087de42b881509b7637b25ea9681871 Mon Sep 17 00:00:00 2001 From: aclement Date: Fri, 25 Jan 2008 19:08:24 +0000 Subject: [PATCH] paramannos: aware of parameter annotation matching --- .../reflect/Java15AnnotationFinder.java | 61 ++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/weaver5/java5-src/org/aspectj/weaver/reflect/Java15AnnotationFinder.java b/weaver5/java5-src/org/aspectj/weaver/reflect/Java15AnnotationFinder.java index 12d211591..e87a89c43 100644 --- a/weaver5/java5-src/org/aspectj/weaver/reflect/Java15AnnotationFinder.java +++ b/weaver5/java5-src/org/aspectj/weaver/reflect/Java15AnnotationFinder.java @@ -26,7 +26,6 @@ import org.aspectj.apache.bcel.classfile.LocalVariable; import org.aspectj.apache.bcel.classfile.LocalVariableTable; import org.aspectj.apache.bcel.util.NonCachingClassLoaderRepository; import org.aspectj.apache.bcel.util.Repository; -import org.aspectj.apache.bcel.util.ClassLoaderRepository; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.UnresolvedType; import org.aspectj.weaver.World; @@ -201,4 +200,64 @@ public class Java15AnnotationFinder implements AnnotationFinder, ArgNameFinder { } return ret; } + public static final ResolvedType[][] NO_PARAMETER_ANNOTATIONS = new ResolvedType[][]{}; + + public ResolvedType[][] getParameterAnnotationTypes(Member onMember) { + if (!(onMember instanceof AccessibleObject)) return NO_PARAMETER_ANNOTATIONS; + // here we really want both the runtime visible AND the class visible annotations + // so we bail out to Bcel and then chuck away the JavaClass so that we don't hog + // memory. + try { + JavaClass jc = bcelRepository.loadClass(onMember.getDeclaringClass()); + org.aspectj.apache.bcel.classfile.annotation.Annotation[][] anns = null; + if (onMember instanceof Method) { + org.aspectj.apache.bcel.classfile.Method bcelMethod = jc.getMethod((Method)onMember); + anns = bcelMethod.getParameterAnnotations(); + } else if (onMember instanceof Constructor) { + org.aspectj.apache.bcel.classfile.Method bcelCons = jc.getMethod((Constructor)onMember); + anns = bcelCons.getParameterAnnotations(); + } else if (onMember instanceof Field) { + anns = null; + } + // the answer is cached and we don't want to hold on to memory + bcelRepository.clear(); + if (anns == null) return NO_PARAMETER_ANNOTATIONS; + ResolvedType[][] result = new ResolvedType[anns.length][]; + // CACHING?? + for (int i=0;i