From 90fef29a3e2966715fe449bbc7ad579bd3516420 Mon Sep 17 00:00:00 2001 From: aclement Date: Mon, 25 Feb 2008 21:41:57 +0000 Subject: [PATCH] annoValMatch: implementation --- .../org/aspectj/weaver/bcel/BcelMethod.java | 34 +++++++++++++++---- .../aspectj/weaver/bcel/BcelObjectType.java | 7 ++-- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java b/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java index 7aa623b20..771245cef 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java @@ -20,6 +20,7 @@ import java.util.Iterator; import java.util.List; import java.util.StringTokenizer; +import org.aspectj.apache.bcel.classfile.AnnotationDefault; import org.aspectj.apache.bcel.classfile.Attribute; import org.aspectj.apache.bcel.classfile.ExceptionTable; import org.aspectj.apache.bcel.classfile.GenericSignatureParser; @@ -221,6 +222,18 @@ public final class BcelMethod extends ResolvedMemberImpl { return null; } + public String getAnnotationDefaultValue() { + Attribute[] attrs = method.getAttributes(); + for (int i = 0; i < attrs.length; i++) { + Attribute attribute = attrs[i]; + if (attribute.getName().equals("AnnotationDefault")) { + AnnotationDefault def = (AnnotationDefault)attribute; + return def.getElementValue().stringifyValue(); + } + } + return null; + } + // for testing - use with the method above public String[] getAttributeNames(boolean onlyIncludeAjOnes) { Attribute[] as = method.getAttributes(); @@ -287,7 +300,7 @@ public final class BcelMethod extends ResolvedMemberImpl { } public boolean hasAnnotation(UnresolvedType ofType) { - ensureAnnotationTypesRetrieved(); + ensureAnnotationsRetrieved(); for (Iterator iter = annotationTypes.iterator(); iter.hasNext();) { ResolvedType aType = (ResolvedType) iter.next(); if (aType.equals(ofType)) return true; @@ -296,19 +309,28 @@ public final class BcelMethod extends ResolvedMemberImpl { } public AnnotationX[] getAnnotations() { - ensureAnnotationTypesRetrieved(); + ensureAnnotationsRetrieved(); return annotations; } public ResolvedType[] getAnnotationTypes() { - ensureAnnotationTypesRetrieved(); + ensureAnnotationsRetrieved(); ResolvedType[] ret = new ResolvedType[annotationTypes.size()]; annotationTypes.toArray(ret); return ret; } + + public AnnotationX getAnnotationOfType(UnresolvedType ofType) { + ensureAnnotationsRetrieved(); + for (int i=0; i