--- /dev/null
+import java.lang.annotation.Annotation;
+
+public abstract aspect GenericAnnotation<A extends Annotation> {
+
+ pointcut annotatedCall(A a) : call(@A * *.*(..)) && @annotation(a);
+
+ before(A a) : annotatedCall(a) {
+ System.err.println("Reference pointcut advice. "+a.annotationType());
+ }
+
+ before(A a) : call(@A * *.*(..)) && @annotation(a) {
+ System.err.println("Inlined pointcut advice. "+a.annotationType());
+ }
+
+}
--- /dev/null
+import java.lang.annotation.*;
+
+public aspect TestSubAspect extends GenericAnnotation<MyAnnotation> {
+
+ public static void main(String []argv) {
+ new BasicType().run();
+ }
+}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface MyAnnotation {}
+
+
+class BasicType {
+ @MyAnnotation
+ public void run() {
+ System.err.println("run running");
+ }
+}
public void testDifferentNumbersofTVars_pr124803() { runTest("generics and different numbers of type variables");}
public void testDifferentNumbersofTVars_pr124803_2() { runTest("generics and different numbers of type variables - classes");}
public void testParameterizedCollectionFieldMatching_pr124808() { runTest("parameterized collection fields matched via pointcut");}
+ public void testGenericAspectsAndAnnotations_pr124654() { runTest("generic aspects and annotations");}
/////////////////////////////////////////
public static Test suite() {
</stderr>
</run>
</ajc-test>
-
+
+ <ajc-test dir="bugs151/pr124654" title="generic aspects and annotations">
+ <compile files="GenericAnnotation.java,TestSubAspect.java" options="-1.5"/>
+ <run class="TestSubAspect">
+ <stderr>
+ <line text="Reference pointcut advice. interface MyAnnotation"/>
+ <line text="Inlined pointcut advice. interface MyAnnotation"/>
+ <line text="run running"/>
+ </stderr>
+ </run>
+ </ajc-test>
</suite>
\ No newline at end of file
import org.aspectj.weaver.Shadow;
import org.aspectj.weaver.ShadowMunger;
import org.aspectj.weaver.TypeVariable;
+import org.aspectj.weaver.TypeVariableReference;
import org.aspectj.weaver.UnresolvedType;
import org.aspectj.weaver.VersionedDataInputStream;
import org.aspectj.weaver.WeaverMessages;
"bad parameter to pointcut reference");
return;
}
- if (!p.matchesSubtypes(parameterTypes[i]) &&
- !p.getExactType().equals(UnresolvedType.OBJECT))
- {
+
+ boolean reportProblem = false;
+ if (parameterTypes[i].isTypeVariableReference() && p.getExactType().isTypeVariableReference()) {
+ UnresolvedType One = ((TypeVariableReference)parameterTypes[i]).getTypeVariable().getFirstBound();
+ UnresolvedType Two = ((TypeVariableReference)p.getExactType()).getTypeVariable().getFirstBound();
+ reportProblem = !One.resolve(scope.getWorld()).isAssignableFrom(Two.resolve(scope.getWorld()));
+ } else {
+ reportProblem = !p.matchesSubtypes(parameterTypes[i]) &&
+ !p.getExactType().equals(UnresolvedType.OBJECT);
+ }
+ if (reportProblem) {
scope.message(IMessage.ERROR, p, "incompatible type, expected " +
parameterTypes[i].getName() + " found " + p +". Check the type specified in your pointcut");
return;