From: aclement Date: Mon, 25 Feb 2008 21:40:59 +0000 (+0000) Subject: annoValMatch: implementation X-Git-Tag: V1_6_0M2~27 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=09050423f273b3015ebe88a329b66da363a68213;p=aspectj.git annoValMatch: implementation --- diff --git a/weaver/src/org/aspectj/weaver/AjAttribute.java b/weaver/src/org/aspectj/weaver/AjAttribute.java index f1d68512e..f338daded 100644 --- a/weaver/src/org/aspectj/weaver/AjAttribute.java +++ b/weaver/src/org/aspectj/weaver/AjAttribute.java @@ -217,12 +217,13 @@ public abstract class AjAttribute { public static short WEAVER_VERSION_MINOR_AJ150 = 0; // These are the weaver major/minor numbers for AspectJ 1.6.0 + public static short WEAVER_VERSION_MAJOR_AJ160M2 = 5; public static short WEAVER_VERSION_MAJOR_AJ160 = 4; public static short WEAVER_VERSION_MINOR_AJ160 = 0; // These are the weaver major/minor versions for *this* weaver - private static short CURRENT_VERSION_MAJOR = WEAVER_VERSION_MAJOR_AJ160; + private static short CURRENT_VERSION_MAJOR = WEAVER_VERSION_MAJOR_AJ160M2; private static short CURRENT_VERSION_MINOR = WEAVER_VERSION_MINOR_AJ160; public static final WeaverVersionInfo UNKNOWN = diff --git a/weaver/src/org/aspectj/weaver/AnnotatedElement.java b/weaver/src/org/aspectj/weaver/AnnotatedElement.java index 9c2c54aa4..bb65e36f6 100644 --- a/weaver/src/org/aspectj/weaver/AnnotatedElement.java +++ b/weaver/src/org/aspectj/weaver/AnnotatedElement.java @@ -16,5 +16,6 @@ public interface AnnotatedElement { boolean hasAnnotation(UnresolvedType ofType); ResolvedType[] getAnnotationTypes(); - // SomeType getAnnotation(UnresolvedType ofType); + + AnnotationX getAnnotationOfType(UnresolvedType ofType); } diff --git a/weaver/src/org/aspectj/weaver/AnnotationX.java b/weaver/src/org/aspectj/weaver/AnnotationX.java index 66a5eaff0..f673aaa4b 100644 --- a/weaver/src/org/aspectj/weaver/AnnotationX.java +++ b/weaver/src/org/aspectj/weaver/AnnotationX.java @@ -206,4 +206,14 @@ public class AnnotationX { else sb.append(theRealASMAnnotation.stringify()); } + public boolean hasNameValuePair(String n, String v) { + if (mode==MODE_BCEL) return theRealBcelAnnotation.hasNameValuePair(n,v); + else throw new RuntimeException("Cannot be anything else"); + } + + public boolean hasNamedValue(String n) { + if (mode==MODE_BCEL) return theRealBcelAnnotation.hasNamedValue(n); + else throw new RuntimeException("Cannot be anything else"); + } + } \ No newline at end of file diff --git a/weaver/src/org/aspectj/weaver/JoinPointSignature.java b/weaver/src/org/aspectj/weaver/JoinPointSignature.java index 3c168e67b..e58dfecaf 100644 --- a/weaver/src/org/aspectj/weaver/JoinPointSignature.java +++ b/weaver/src/org/aspectj/weaver/JoinPointSignature.java @@ -91,6 +91,10 @@ public class JoinPointSignature implements ResolvedMember { public ResolvedType[] getAnnotationTypes() { return realMember.getAnnotationTypes(); } + + public AnnotationX getAnnotationOfType(UnresolvedType ofType) { + return realMember.getAnnotationOfType(ofType); + } public void setAnnotationTypes(UnresolvedType[] annotationtypes) { realMember.setAnnotationTypes(annotationtypes); @@ -419,4 +423,8 @@ public class JoinPointSignature implements ResolvedMember { public ResolvedMember parameterizedWith(Map m, World w) { return realMember.parameterizedWith(m,w); } + + public String getAnnotationDefaultValue() { + return realMember.getAnnotationDefaultValue(); + } } diff --git a/weaver/src/org/aspectj/weaver/MemberImpl.java b/weaver/src/org/aspectj/weaver/MemberImpl.java index d984f2e84..03aba64c2 100644 --- a/weaver/src/org/aspectj/weaver/MemberImpl.java +++ b/weaver/src/org/aspectj/weaver/MemberImpl.java @@ -486,6 +486,10 @@ public class MemberImpl implements Comparable, AnnotatedElement,Member { public ResolvedType[][] getParameterAnnotationTypes() { throw new UnsupportedOperationException("You should resolve this member and call getParameterAnnotationTypes() on the result..."); } + public String getAnnotationDefaultValue() { + throw new UnsupportedOperationException("You should resolve this member and call getAnnotationDefaultValue() on the result..."); + } + /* (non-Javadoc) * @see org.aspectj.weaver.Member#getSignature() */ @@ -628,16 +632,14 @@ public class MemberImpl implements Comparable, AnnotatedElement,Member { throw new UnsupportedOperationException("You should resolve this member and call hasAnnotation() on the result..."); } - /* (non-Javadoc) - * @see org.aspectj.weaver.AnnotatedElement#getAnnotationTypes() - */ - /* (non-Javadoc) - * @see org.aspectj.weaver.Member#getAnnotationTypes() - */ public ResolvedType[] getAnnotationTypes() { throw new UnsupportedOperationException("You should resolve this member and call hasAnnotation() on the result..."); } - + + public AnnotationX getAnnotationOfType(UnresolvedType ofType) { + throw new UnsupportedOperationException("You should resolve this member and call getAnnotationOfType() on the result..."); + } + /* (non-Javadoc) * @see org.aspectj.weaver.Member#getAnnotations() */ diff --git a/weaver/src/org/aspectj/weaver/ResolvedType.java b/weaver/src/org/aspectj/weaver/ResolvedType.java index 6a01e3ca1..6399cb985 100644 --- a/weaver/src/org/aspectj/weaver/ResolvedType.java +++ b/weaver/src/org/aspectj/weaver/ResolvedType.java @@ -116,6 +116,10 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl return EMPTY_RESOLVED_TYPE_ARRAY; } + public AnnotationX getAnnotationOfType(UnresolvedType ofType) { + return null; + } + public final UnresolvedType getSuperclass(World world) { return getSuperclass(); } diff --git a/weaver/src/org/aspectj/weaver/WeaverMessages.java b/weaver/src/org/aspectj/weaver/WeaverMessages.java index d58251c70..00b2e1f01 100644 --- a/weaver/src/org/aspectj/weaver/WeaverMessages.java +++ b/weaver/src/org/aspectj/weaver/WeaverMessages.java @@ -146,6 +146,10 @@ public class WeaverMessages { public static final String INCORRECT_TARGET_FOR_DECLARE_ANNOTATION = "incorrectTargetForDeclareAnnotation"; public static final String NO_MATCH_BECAUSE_SOURCE_RETENTION = "noMatchBecauseSourceRetention"; + // Annotation Value messages + public static final String INVALID_ANNOTATION_VALUE = "invalidAnnotationValue"; + public static final String UNKNOWN_ANNOTATION_VALUE = "unknownAnnotationValue"; + // < Java5 messages public static final String ATANNOTATION_ONLY_SUPPORTED_AT_JAVA5_LEVEL = "atannotationNeedsJava5"; public static final String ATWITHIN_ONLY_SUPPORTED_AT_JAVA5_LEVEL = "atwithinNeedsJava5"; diff --git a/weaver/src/org/aspectj/weaver/weaver-messages.properties b/weaver/src/org/aspectj/weaver/weaver-messages.properties index af5ab65d2..77c9b0031 100644 --- a/weaver/src/org/aspectj/weaver/weaver-messages.properties +++ b/weaver/src/org/aspectj/weaver/weaver-messages.properties @@ -157,6 +157,10 @@ referenceToNonAnnotationType=Type referred to is not an annotation type: {0} bindingNonRuntimeRetentionAnnotation=Annotation type {0} does not have runtime retention noMatchBecauseSourceRetention=Failing match because annotation ''{0}'' on type ''{1}'' has SOURCE retention. Matching allowed when RetentionPolicy is CLASS or RUNTIME +# Annotation value +invalidAnnotationValue=Invalid annotation value ''{0}'', expected {1} value +unknownAnnotationValue=The annotation ''{0}'' does not define a value named ''{1}'' + # Generics cantDecpMultipleParameterizations=Cannot declare parent {0} onto type {1} since it already has {2} in its hierarchy noParameterizedTypePatternInHandler=a parameterized type pattern may not be used in a handler pointcut expression