]> source.dussan.org Git - aspectj.git/commitdiff
fix bug whereby we were statically matching annotations that we shouldn't
authoracolyer <acolyer>
Fri, 11 Feb 2005 12:56:35 +0000 (12:56 +0000)
committeracolyer <acolyer>
Fri, 11 Feb 2005 12:56:35 +0000 (12:56 +0000)
weaver/src/org/aspectj/weaver/patterns/AnnotationPatternList.java
weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java
weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java
weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java

index 8361e65e459579bc1aa135ffb6a2179a8685694b..71be36a23f4adc36cd65bc9883eb4a5d3c4ab018 100644 (file)
@@ -83,7 +83,7 @@ public class AnnotationPatternList extends PatternNode {
                                // match the argument type at argsIndex with the ExactAnnotationTypePattern
                                // we know it is exact because nothing else is allowed in args
                                ExactAnnotationTypePattern ap = (ExactAnnotationTypePattern)typePatterns[i];
-                               FuzzyBoolean matches = ap.matches(someArgs[argsIndex]);
+                               FuzzyBoolean matches = ap.matchesRuntimeType(someArgs[argsIndex]);
                                if (matches == FuzzyBoolean.NO) {
                                        return FuzzyBoolean.MAYBE;  // could still match at runtime
                                } else {
index 5ba432e81f14c79b3d82fee621a21bac29521f95..fdc09557dc0143ee7eca6b39373dfd9b64c3a1e1 100644 (file)
@@ -138,6 +138,7 @@ public class ArgsAnnotationPointcut extends NameBindingPointcut {
                            "",IMessage.ERROR,shadow.getSourceLocation(),null,new ISourceLocation[]{getSourceLocation()});
                    }
                                if (ap.matches(rArgType).alwaysTrue()) { // !!! ASC Can we ever take this branch?
+                                                                            // !!! AMC - Yes, if annotation is @Inherited
                                        argsIndex++;
                                        continue;
                                } else {
index 23a36e84da1aab7b2ee3317419b509fd3f362117..811874fe49aaccbf83ee8b2b709bb2881c287e33 100644 (file)
@@ -78,6 +78,18 @@ public class ExactAnnotationTypePattern extends AnnotationTypePattern {
                } 
                return FuzzyBoolean.NO;
        }
+       
+       // this version should be called for @this, @target, @args
+       public FuzzyBoolean matchesRuntimeType(AnnotatedElement annotated) {
+               if (annotationType.hasAnnotation(TypeX.AT_INHERITED)) {
+                       // a static match is good enough
+                       if (matches(annotated).alwaysTrue()) {
+                               return FuzzyBoolean.YES;
+                       } 
+               }
+               // a subtype could match at runtime
+               return FuzzyBoolean.MAYBE;
+       }
 
        
        public void resolve(World world) {
index c06ec95e25fd1594aa725785256b6d3a11d4e8a7..6aff2dbd973031c230dd95dfbe2cffd4ca30c36a 100644 (file)
@@ -88,7 +88,7 @@ public class ThisOrTargetAnnotationPointcut extends NameBindingPointcut {
            ResolvedTypeX toMatchAgainst = 
                (isThis ? shadow.getThisType() : shadow.getTargetType() ).resolve(shadow.getIWorld());
            annotationTypePattern.resolve(shadow.getIWorld());
-           if (annotationTypePattern.matches(toMatchAgainst).alwaysTrue()) {
+           if (annotationTypePattern.matchesRuntimeType(toMatchAgainst).alwaysTrue()) {
                return FuzzyBoolean.YES;
            } else {
                // a subtype may match at runtime