diff options
author | acolyer <acolyer> | 2005-03-10 13:00:42 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-03-10 13:00:42 +0000 |
commit | 922aeaa57dcb071c5a3007827c2268d707e557f2 (patch) | |
tree | d321aa33c41841eb9853d131f0eb5d1dd11162db | |
parent | 074251e1666235f1eb62e5406821e8d05178ce9a (diff) | |
download | aspectj-922aeaa57dcb071c5a3007827c2268d707e557f2.tar.gz aspectj-922aeaa57dcb071c5a3007827c2268d707e557f2.zip |
fixes for annotation type pattern bugs uncovered in 150 tests
6 files changed, 22 insertions, 16 deletions
diff --git a/tests/java5/annotations/ajdkExamples/RuntimeTypeMatching.aj b/tests/java5/annotations/ajdkExamples/RuntimeTypeMatching.aj index 16d85affc..086bea247 100644 --- a/tests/java5/annotations/ajdkExamples/RuntimeTypeMatching.aj +++ b/tests/java5/annotations/ajdkExamples/RuntimeTypeMatching.aj @@ -89,11 +89,10 @@ public aspect RuntimeTypeMatching { before() : insideCriticalMethod(Critical) { Signature sig = thisEnclosingJoinPointStaticPart.getSignature(); AnnotatedElement declaringTypeAnnotationInfo = sig.getDeclaringType(); - if (sig instanceof MemberSignature) { - // this must be an initialization, pre-initialization, call, execution, get, or - // set join point. - AnnotatedElement memberAnnotationInfo = ((MemberSignature)sig).getAccessibleObject(); - Critical c = memberAnnotationInfo.getAnnotation(Critical.class); + if (sig instanceof MethodSignature) { + // this must be a call or execution join point. + Method method = ((MethodSignature)sig).getMethod(); + Critical c = method.getAnnotation(Critical.class); System.out.println("Entering critical join point with reflectively obtained priority " + c.priority()); } } diff --git a/tests/java5/pertypewithin/ajdk/AJDKExamples.aj b/tests/java5/pertypewithin/ajdk/AJDKExamples.aj index 433270cf4..a03c72643 100644 --- a/tests/java5/pertypewithin/ajdk/AJDKExamples.aj +++ b/tests/java5/pertypewithin/ajdk/AJDKExamples.aj @@ -1,5 +1,6 @@ +package org.xyz.foo; import java.util.*; -public aspect AJDKExamples pertypewithin(org.xyz..*) { +public aspect AJDKExamples pertypewithin(org.xyz..* && !AJDKExamples) { // use WeakHashMap for auto-garbage collection of keys private Map<Object,Boolean> instances = new WeakHashMap<Object,Boolean>(); diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index 4ef1703da..7329d2996 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -1111,14 +1111,16 @@ <ajc-test dir="java5/annotations/ajdkExamples" title="ajdk: runtime annotations"> <compile files="RuntimeTypeMatching.aj" options="-1.5"> + <message kind="warning" line="121" text="@within(Foo)"/> <message kind="warning" line="122" text="@within(Foo)"/> - <message kind="warning" line="123" text="@within(Foo)"/> </compile> <run class="RuntimeTypeMatching"> <stdout> <line text="This information is TOP-SECRET"/> <line text="@target(Classified) at call(void A.a())"/> <line text="@this(Foo) at execution(void B.b())"/> + <line text="Classified data being passed at call(void B.callA(A))"/> + <line text="Classified data being passed at execution(void B.callA(A))"/> <line text="This information is TOP-SECRET"/> <line text="@target(Classified) at call(Class java.lang.Object.getClass())"/> <line text="1 @Foo()"/> @@ -1234,12 +1236,12 @@ <ajc-test dir="java5/pertypewithin/ajdk" title="ajdk: ptw"> <compile files="AJDKExamples.aj" options="-1.5"/> - <run class="AJDKExamples"> + <run class="org.xyz.foo.AJDKExamples"> <stdout> <line text="true"/> <line text="true"/> - <line text="There are 3 As"/> - <line text="There are 2 Bs"/> + <line text="There are 2 As"/> + <line text="There are 3 Bs"/> </stdout> </run> </ajc-test> diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java index 1c2f7f443..42635aa78 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java @@ -900,11 +900,14 @@ public class BcelWeaver implements IWeaver { if (element instanceof BcelAdvice) { // This will stop us incorrectly reporting deow Checkers BcelAdvice ba = (BcelAdvice)element; if (!ba.hasMatchedSomething()) { - Annotation[] anns = ((BcelMethod)ba.getSignature()).getAnnotations(); - // Check if they want to suppress the warning on this piece of advice - if (!Utility.isSuppressing(anns,"adviceDidNotMatch")) { - world.getLint().adviceDidNotMatch.signal(ba.getDeclaringAspect().getNameAsIdentifier(),element.getSourceLocation()); - } + BcelMethod meth = ((BcelMethod)ba.getSignature()); + if (meth != null) { + Annotation[] anns = meth.getAnnotations(); + // Check if they want to suppress the warning on this piece of advice + if (!Utility.isSuppressing(anns,"adviceDidNotMatch")) { + world.getLint().adviceDidNotMatch.signal(ba.getDeclaringAspect().getNameAsIdentifier(),element.getSourceLocation()); + } + } } } } diff --git a/weaver/src/org/aspectj/weaver/patterns/AnnotationPatternList.java b/weaver/src/org/aspectj/weaver/patterns/AnnotationPatternList.java index cca0c32c3..df3833009 100644 --- a/weaver/src/org/aspectj/weaver/patterns/AnnotationPatternList.java +++ b/weaver/src/org/aspectj/weaver/patterns/AnnotationPatternList.java @@ -82,6 +82,7 @@ public class AnnotationPatternList extends PatternNode { } else { // match the argument type at argsIndex with the ExactAnnotationTypePattern // we know it is exact because nothing else is allowed in args + if (someArgs[argsIndex].isPrimitive()) return FuzzyBoolean.NO; // can never match ExactAnnotationTypePattern ap = (ExactAnnotationTypePattern)typePatterns[i]; FuzzyBoolean matches = ap.matchesRuntimeType(someArgs[argsIndex]); if (matches == FuzzyBoolean.NO) { diff --git a/weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java b/weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java index fdc09557d..dfb97e743 100644 --- a/weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java @@ -147,7 +147,7 @@ public class ArgsAnnotationPointcut extends NameBindingPointcut { if (ap instanceof BindingAnnotationTypePattern) { BindingAnnotationTypePattern btp = (BindingAnnotationTypePattern)ap; Var annvar = shadow.getArgAnnotationVar(argsIndex,rAnnType); - state.set(argsIndex,annvar); + state.set(btp.getFormalIndex(),annvar); ret = Test.makeAnd(ret,Test.makeHasAnnotation(shadow.getArgVar(argsIndex),rAnnType)); argsIndex++; } else { |