]> source.dussan.org Git - aspectj.git/commitdiff
wip param_anno_matching_change
authorAndy Clement <aclement@pivotal.io>
Wed, 18 Apr 2018 15:29:35 +0000 (08:29 -0700)
committerAndy Clement <aclement@pivotal.io>
Wed, 18 Apr 2018 15:29:35 +0000 (08:29 -0700)
14 files changed:
org.aspectj.matcher/src/org/aspectj/weaver/patterns/SignaturePattern.java
tests/bugs190/532210/Code.java [new file with mode: 0644]
tests/bugs190/532210/Code2.class [new file with mode: 0644]
tests/bugs190/532210/Code2.java [new file with mode: 0644]
tests/bugs190/532210/Code3.class [new file with mode: 0644]
tests/bugs190/532210/Code3.java [new file with mode: 0644]
tests/bugs190/532210/I.class [new file with mode: 0644]
tests/bugs190/532210/Nullable.class [new file with mode: 0644]
tests/bugs190/532210/P.class [new file with mode: 0644]
tests/bugs190/532210/PA.class [new file with mode: 0644]
tests/bugs190/532210/TA.class [new file with mode: 0644]
tests/bugs190/532210/X.class [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc190/Ajc190Tests.java
tests/src/org/aspectj/systemtest/ajc190/ajc190.xml

index 365b5b7a7979c01da34acfb5f5db45b1382162cb..3fcc2eb0bbb6d5b8b61c4d92ae221872feb1a52f 100644 (file)
@@ -532,18 +532,27 @@ public class SignaturePattern extends PatternNode implements ISignaturePattern {
                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...
                        }
diff --git a/tests/bugs190/532210/Code.java b/tests/bugs190/532210/Code.java
new file mode 100644 (file)
index 0000000..da614d2
--- /dev/null
@@ -0,0 +1,17 @@
+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) { }
+}
diff --git a/tests/bugs190/532210/Code2.class b/tests/bugs190/532210/Code2.class
new file mode 100644 (file)
index 0000000..cad1870
Binary files /dev/null and b/tests/bugs190/532210/Code2.class differ
diff --git a/tests/bugs190/532210/Code2.java b/tests/bugs190/532210/Code2.java
new file mode 100644 (file)
index 0000000..bcc9d79
--- /dev/null
@@ -0,0 +1,18 @@
+import java.lang.annotation.*;
+
+/*
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@interface Nullable {}
+
+@Nullable
+interface I {
+       void n();
+}
+
+*/
+public class Code2 {
+       public static void main(String []argv) {
+               Object o = (Object[])argv;
+       }
+}
diff --git a/tests/bugs190/532210/Code3.class b/tests/bugs190/532210/Code3.class
new file mode 100644 (file)
index 0000000..3141cf9
Binary files /dev/null and b/tests/bugs190/532210/Code3.class differ
diff --git a/tests/bugs190/532210/Code3.java b/tests/bugs190/532210/Code3.java
new file mode 100644 (file)
index 0000000..c644ab6
--- /dev/null
@@ -0,0 +1,24 @@
+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) {}
+}
diff --git a/tests/bugs190/532210/I.class b/tests/bugs190/532210/I.class
new file mode 100644 (file)
index 0000000..b0971e1
Binary files /dev/null and b/tests/bugs190/532210/I.class differ
diff --git a/tests/bugs190/532210/Nullable.class b/tests/bugs190/532210/Nullable.class
new file mode 100644 (file)
index 0000000..b4134f5
Binary files /dev/null and b/tests/bugs190/532210/Nullable.class differ
diff --git a/tests/bugs190/532210/P.class b/tests/bugs190/532210/P.class
new file mode 100644 (file)
index 0000000..6493110
Binary files /dev/null and b/tests/bugs190/532210/P.class differ
diff --git a/tests/bugs190/532210/PA.class b/tests/bugs190/532210/PA.class
new file mode 100644 (file)
index 0000000..a73ebdb
Binary files /dev/null and b/tests/bugs190/532210/PA.class differ
diff --git a/tests/bugs190/532210/TA.class b/tests/bugs190/532210/TA.class
new file mode 100644 (file)
index 0000000..62faabf
Binary files /dev/null and b/tests/bugs190/532210/TA.class differ
diff --git a/tests/bugs190/532210/X.class b/tests/bugs190/532210/X.class
new file mode 100644 (file)
index 0000000..c53448b
Binary files /dev/null and b/tests/bugs190/532210/X.class differ
index 3d3659f774bdf8012bc6461fa9d2169241cf692e..2f003cfbeddc5eebc4a8f47f3a007c726230cbdc 100644 (file)
@@ -22,6 +22,10 @@ import junit.framework.Test;
  */
 public class Ajc190Tests extends XMLBasedAjcTestCaseForJava9OrLater {
 
+       public void testParamAnnoInheritance() {
+               runTest("param anno inheritance");
+       }
+
        public void testParamAnnosNegative() {
                runTest("param annos negative");
        }
index dc311f63fcc8fa7e1b9171c30a59073b3427381d..a603e96471d1eae5e846841020d21fc1282734c3 100644 (file)
@@ -2,6 +2,11 @@
 
 <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">
@@ -9,7 +14,6 @@
        </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>