ResolvableTypeList rtl = new ResolvableTypeList(world, aMethod.getParameterTypes());
// Only fetch the parameter annotations if the pointcut is going to be matching on them
ResolvedType[][] parameterAnnotationTypes = null;
- if (isMatchingParameterAnnotations()) {
+ boolean paramAnnoMatching = false;
+ // if there are parameterAnnotationTypes then only be concerned if a subjectMatch
+ if (subjectMatch && isMatchingParameterAnnotations()) {
parameterAnnotationTypes = aMethod.getParameterAnnotationTypes();
if (parameterAnnotationTypes != null && parameterAnnotationTypes.length == 0) {
parameterAnnotationTypes = null;
}
+ paramAnnoMatching = true;
}
if (!parameterTypes.matches(rtl, TypePattern.STATIC, parameterAnnotationTypes).alwaysTrue()) {
// It could still be a match based on the generic sig parameter types of a parameterized type
- if (!parameterTypes.matches(new ResolvableTypeList(world, aMethod.getGenericParameterTypes()), TypePattern.STATIC,
- parameterAnnotationTypes).alwaysTrue()) {
+ FuzzyBoolean matches = parameterTypes.matches(new ResolvableTypeList(world, aMethod.getGenericParameterTypes()), TypePattern.STATIC,
+ parameterAnnotationTypes);
+ if (!matches.alwaysTrue()) {
+ if (paramAnnoMatching && matches.alwaysFalse()) {
+ return FuzzyBoolean.NO;
+ }
return FuzzyBoolean.MAYBE;
+// return FuzzyBoolean.NO;//
+// return matches.alwaysFalse()?FuzzyBoolean.NO:FuzzyBoolean.MAYBE;
// It could STILL be a match based on the erasure of the parameter types??
// to be determined via test cases...
}
--- /dev/null
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Nullable {}
+
+interface I {
+ void n(Object o);
+}
+
+public class Code implements I {
+ public void m(@Nullable Object v) {}
+ @Override public void n(@Nullable Object v) {}
+}
+
+aspect X {
+ before(Object o): execution(* *(!@Nullable (*))) && args(o) { }
+}
--- /dev/null
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface PA {}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface TA {}
+
+@TA class P {}
+
+aspect X {
+ declare warning: execution(* a(@PA (@TA *))): "has param anno and type anno";
+}
+
+public class Code3 {
+ public static void main(String []argv) {
+ Object o = (Object[])argv;
+ }
+
+ public void a(P p) {}
+ public void b(String q) {}
+ public void c(@PA P p) {}
+ public void d(@PA String q) {}
+}
<suite>
+ <ajc-test dir="bugs190/532210" title="param anno inheritance">
+ <compile files="Code.java" options="-1.9 -showWeaveInfo">
+ <message kind="warning" text="advice defined in X has not been applied"/>
+ </compile>
+ </ajc-test>
<ajc-test dir="bugs190/paramannos" title="param annos negative">
<compile files="Code.java" options="-1.9 -showWeaveInfo">
</compile>
</ajc-test>
-
<ajc-test dir="bugs190/modules/aaa" title="build a module">
<compile files="module-info.java com/foo1/C1.java" options="-1.9"/>
</ajc-test>