From: Andy Clement Date: Wed, 28 Feb 2018 20:07:51 +0000 (-0800) Subject: Fix for Bug 531819 - Negative parameter annotation matching not behaving X-Git-Tag: V1_9_0~10 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6b620ba3aa4b0c9d29560dfa42f8c67dcafb1229;p=aspectj.git Fix for Bug 531819 - Negative parameter annotation matching not behaving --- diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/Type.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/Type.java index 36d6d7d72..e1dc47348 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/Type.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/Type.java @@ -91,6 +91,7 @@ public abstract class Type { public static final ObjectType STRING = new ObjectType("java.lang.String"); public static final ObjectType OBJECT_ARRAY = new ObjectType("java.lang.Object[]"); public static final ObjectType STRING_ARRAY = new ObjectType("java.lang.String[]"); + public static final ObjectType CLASS_ARRAY = new ObjectType("java.lang.Class[]"); public static final ObjectType STRINGBUFFER = new ObjectType("java.lang.StringBuffer"); public static final ObjectType STRINGBUILDER = new ObjectType("java.lang.StringBuilder"); public static final ObjectType THROWABLE = new ObjectType("java.lang.Throwable"); diff --git a/lib/bcel/bcel-src.zip b/lib/bcel/bcel-src.zip index 5a2fc5dc7..1cbe73979 100644 Binary files a/lib/bcel/bcel-src.zip and b/lib/bcel/bcel-src.zip differ diff --git a/lib/bcel/bcel-verifier.jar b/lib/bcel/bcel-verifier.jar index 1f9edfddc..b55ed6429 100644 Binary files a/lib/bcel/bcel-verifier.jar and b/lib/bcel/bcel-verifier.jar differ diff --git a/lib/bcel/bcel.jar b/lib/bcel/bcel.jar index 57f1b9c0a..2306787c5 100644 Binary files a/lib/bcel/bcel.jar and b/lib/bcel/bcel.jar differ 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 a4bf804af..365b5b7a7 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/SignaturePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/SignaturePattern.java @@ -72,6 +72,7 @@ public class SignaturePattern extends PatternNode implements ISignaturePattern { this.isExactDeclaringTypePattern = (declaringType instanceof ExactTypePattern); } + @Override public SignaturePattern resolveBindings(IScope scope, Bindings bindings) { if (returnType != null) { returnType = returnType.resolveBindings(scope, bindings, false, false); @@ -290,6 +291,7 @@ public class SignaturePattern extends PatternNode implements ISignaturePattern { * return a copy of this signature pattern in which every type variable reference is replaced by the corresponding entry in the * map. */ + @Override public SignaturePattern parameterizeWith(Map typeVariableMap, World w) { SignaturePattern ret = new SignaturePattern(kind, modifiers, returnType.parameterizeWith(typeVariableMap, w), declaringType .parameterizeWith(typeVariableMap, w), name, parameterTypes.parameterizeWith(typeVariableMap, w), throwsPattern @@ -298,6 +300,7 @@ public class SignaturePattern extends PatternNode implements ISignaturePattern { return ret; } + @Override public boolean matches(Member joinPointSignature, World world, boolean allowBridgeMethods) { // fail (or succeed!) fast tests... if (joinPointSignature == null) { @@ -628,7 +631,7 @@ public class SignaturePattern extends PatternNode implements ISignaturePattern { if (!parameterTypes.matches(resolvedParameters, TypePattern.STATIC, parameterAnnotationTypes).alwaysTrue()) { // It could still be a match based on the generic sig parameter types of a parameterized type - if (!parameterTypes.matches(world.resolve(aConstructor.getGenericParameterTypes()), TypePattern.STATIC).alwaysTrue()) { + if (!parameterTypes.matches(world.resolve(aConstructor.getGenericParameterTypes()), TypePattern.STATIC, parameterAnnotationTypes).alwaysTrue()) { return FuzzyBoolean.MAYBE; // It could STILL be a match based on the erasure of the parameter types?? // to be determined via test cases... @@ -968,6 +971,7 @@ public class SignaturePattern extends PatternNode implements ISignaturePattern { return annotationPattern; } + @Override public boolean isStarAnnotation() { return annotationPattern == AnnotationTypePattern.ANY; } @@ -981,10 +985,12 @@ public class SignaturePattern extends PatternNode implements ISignaturePattern { return isExactDeclaringTypePattern; } + @Override public boolean isMatchOnAnyName() { return getName().isAny(); } + @Override public List getExactDeclaringTypes() { if (declaringType instanceof ExactTypePattern) { List l = new ArrayList(); @@ -995,6 +1001,7 @@ public class SignaturePattern extends PatternNode implements ISignaturePattern { } } + @Override public boolean couldEverMatch(ResolvedType type) { return declaringType.matches(type, TypePattern.STATIC).maybeTrue(); } diff --git a/tests/bugs190/paramannos/Code.java b/tests/bugs190/paramannos/Code.java new file mode 100644 index 000000000..1ab184346 --- /dev/null +++ b/tests/bugs190/paramannos/Code.java @@ -0,0 +1,13 @@ +import java.lang.annotation.*; + +@Retention(RetentionPolicy.RUNTIME) +@interface Anno {} + +public class Code { + public Code(@Anno String boo) {} + public Code(Object boo) {} +} + +aspect X { + before(): execution(new(!@Anno (*))) { } +} diff --git a/tests/src/org/aspectj/systemtest/ajc190/Ajc190Tests.java b/tests/src/org/aspectj/systemtest/ajc190/Ajc190Tests.java index 613c1247a..3d3659f77 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 testParamAnnosNegative() { + runTest("param annos negative"); + } + public void testAnnotMethodHasMember_pr156962_1() { // From similar in Ajc153Tests runTest("Test Annot Method Has Member 1"); } diff --git a/tests/src/org/aspectj/systemtest/ajc190/AllTestsAspectJ190.java b/tests/src/org/aspectj/systemtest/ajc190/AllTestsAspectJ190.java index 4f795f960..2ebc12e7c 100644 --- a/tests/src/org/aspectj/systemtest/ajc190/AllTestsAspectJ190.java +++ b/tests/src/org/aspectj/systemtest/ajc190/AllTestsAspectJ190.java @@ -20,6 +20,7 @@ public class AllTestsAspectJ190 { // $JUnit-BEGIN$ suite.addTest(Ajc190Tests.suite()); suite.addTest(SanityTests19.suite()); +// suite.addTest(EfficientTJPTests.suite()); suite.addTest(ModuleTests.suite()); suite.addTest(Annotations.suite()); // $JUnit-END$ diff --git a/tests/src/org/aspectj/systemtest/ajc190/ajc190.xml b/tests/src/org/aspectj/systemtest/ajc190/ajc190.xml index b69926377..dc311f63f 100644 --- a/tests/src/org/aspectj/systemtest/ajc190/ajc190.xml +++ b/tests/src/org/aspectj/systemtest/ajc190/ajc190.xml @@ -2,6 +2,14 @@ + + + + + + + +