From: Andy Clement Date: Wed, 18 Apr 2018 15:29:35 +0000 (-0700) Subject: wip X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fheads%2Fparam_anno_matching_change;p=aspectj.git wip --- diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/SignaturePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/SignaturePattern.java index 365b5b7a7..3fcc2eb0b 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/SignaturePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/SignaturePattern.java @@ -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 index 000000000..da614d2df --- /dev/null +++ b/tests/bugs190/532210/Code.java @@ -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 index 000000000..cad1870fb 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 index 000000000..bcc9d79a8 --- /dev/null +++ b/tests/bugs190/532210/Code2.java @@ -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 index 000000000..3141cf945 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 index 000000000..c644ab633 --- /dev/null +++ b/tests/bugs190/532210/Code3.java @@ -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 index 000000000..b0971e159 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 index 000000000..b4134f57f 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 index 000000000..649311021 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 index 000000000..a73ebdb68 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 index 000000000..62faabf6e 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 index 000000000..c53448b2c Binary files /dev/null and b/tests/bugs190/532210/X.class differ diff --git a/tests/src/org/aspectj/systemtest/ajc190/Ajc190Tests.java b/tests/src/org/aspectj/systemtest/ajc190/Ajc190Tests.java index 3d3659f77..2f003cfbe 100644 --- a/tests/src/org/aspectj/systemtest/ajc190/Ajc190Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc190/Ajc190Tests.java @@ -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"); } diff --git a/tests/src/org/aspectj/systemtest/ajc190/ajc190.xml b/tests/src/org/aspectj/systemtest/ajc190/ajc190.xml index dc311f63f..a603e9647 100644 --- a/tests/src/org/aspectj/systemtest/ajc190/ajc190.xml +++ b/tests/src/org/aspectj/systemtest/ajc190/ajc190.xml @@ -2,6 +2,11 @@ + + + + + @@ -9,7 +14,6 @@ -