Browse Source

fixes for annotation type pattern bugs uncovered in 150 tests

tags/V1_5_0M2
acolyer 19 years ago
parent
commit
922aeaa57d

+ 4
- 5
tests/java5/annotations/ajdkExamples/RuntimeTypeMatching.aj View File

@@ -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());
}
}

+ 2
- 1
tests/java5/pertypewithin/ajdk/AJDKExamples.aj View File

@@ -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>();

+ 6
- 4
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml View File

@@ -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>

+ 8
- 5
weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java View File

@@ -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());
}
}
}
}
}

+ 1
- 0
weaver/src/org/aspectj/weaver/patterns/AnnotationPatternList.java View File

@@ -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) {

+ 1
- 1
weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java View File

@@ -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 {

Loading…
Cancel
Save