summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoracolyer <acolyer>2005-02-11 12:56:35 +0000
committeracolyer <acolyer>2005-02-11 12:56:35 +0000
commitfde9f247531b5257ebdff886054e9fd6cfd3e03d (patch)
tree2d8f3ea1d44d57f39152896a334135954708cd42
parent1381903ac81cdab2b79b6525096671aa5d62eaeb (diff)
downloadaspectj-fde9f247531b5257ebdff886054e9fd6cfd3e03d.tar.gz
aspectj-fde9f247531b5257ebdff886054e9fd6cfd3e03d.zip
fix bug whereby we were statically matching annotations that we shouldn't
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/AnnotationPatternList.java2
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java1
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java12
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java2
4 files changed, 15 insertions, 2 deletions
diff --git a/weaver/src/org/aspectj/weaver/patterns/AnnotationPatternList.java b/weaver/src/org/aspectj/weaver/patterns/AnnotationPatternList.java
index 8361e65e4..71be36a23 100644
--- a/weaver/src/org/aspectj/weaver/patterns/AnnotationPatternList.java
+++ b/weaver/src/org/aspectj/weaver/patterns/AnnotationPatternList.java
@@ -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 {
diff --git a/weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java b/weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java
index 5ba432e81..fdc09557d 100644
--- a/weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java
@@ -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 {
diff --git a/weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java
index 23a36e84d..811874fe4 100644
--- a/weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java
@@ -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) {
diff --git a/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java b/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java
index c06ec95e2..6aff2dbd9 100644
--- a/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java
@@ -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