]> source.dussan.org Git - aspectj.git/commitdiff
Fix for Bug 531819 - Negative parameter annotation matching not behaving
authorAndy Clement <aclement@pivotal.io>
Wed, 28 Feb 2018 20:07:51 +0000 (12:07 -0800)
committerAndy Clement <aclement@pivotal.io>
Wed, 28 Feb 2018 20:07:51 +0000 (12:07 -0800)
bcel-builder/src/org/aspectj/apache/bcel/generic/Type.java
lib/bcel/bcel-src.zip
lib/bcel/bcel-verifier.jar
lib/bcel/bcel.jar
org.aspectj.matcher/src/org/aspectj/weaver/patterns/SignaturePattern.java
tests/bugs190/paramannos/Code.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc190/Ajc190Tests.java
tests/src/org/aspectj/systemtest/ajc190/AllTestsAspectJ190.java
tests/src/org/aspectj/systemtest/ajc190/ajc190.xml

index 36d6d7d72e6e9ee1683d18802bcf828fa602642e..e1dc47348ed033301b776a7a521e050535a4ef20 100644 (file)
@@ -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");
index 5a2fc5dc7aba9a860ef4d3c065e03ed05fc5b395..1cbe73979fb21d8f855bdc0ce4e77776879f0d64 100644 (file)
Binary files a/lib/bcel/bcel-src.zip and b/lib/bcel/bcel-src.zip differ
index 1f9edfddcec61369ffb6b48cbd09aa72041db1ad..b55ed6429665e6bfc63d4ad70e07e8914386e199 100644 (file)
Binary files a/lib/bcel/bcel-verifier.jar and b/lib/bcel/bcel-verifier.jar differ
index 57f1b9c0a40c56e5eb1f8b263546ca8ae1c076bf..2306787c522b960da9977a3d817ff7ab44968aef 100644 (file)
Binary files a/lib/bcel/bcel.jar and b/lib/bcel/bcel.jar differ
index a4bf804afd980d2abea4bfcd08db9f41d8bb0519..365b5b7a7979c01da34acfb5f5db45b1382162cb 100644 (file)
@@ -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<String, UnresolvedType> 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<ExactTypePattern> getExactDeclaringTypes() {
                if (declaringType instanceof ExactTypePattern) {
                        List<ExactTypePattern> l = new ArrayList<ExactTypePattern>();
@@ -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 (file)
index 0000000..1ab1843
--- /dev/null
@@ -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 (*))) { }
+}
index 613c1247a17f0cb10b0dbfcfc6f5e0930c87a9bb..3d3659f774bdf8012bc6461fa9d2169241cf692e 100644 (file)
@@ -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");
        }
index 4f795f9604cba7ea61330f51759fd08cd0dc4165..2ebc12e7c6c8e916a8994a7f0f1c3f938e5d510c 100644 (file)
@@ -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$
index b699263770302bf3feb16bc82e1361a2f5c0ce79..dc311f63fcc8fa7e1b9171c30a59073b3427381d 100644 (file)
@@ -2,6 +2,14 @@
 
 <suite>
 
+
+  <ajc-test dir="bugs190/paramannos" title="param annos negative">
+    <compile files="Code.java" options="-1.9 -showWeaveInfo">
+               <message kind="weave" text="Join point 'constructor-execution(void Code.&lt;init&gt;(java.lang.Object))' in Type 'Code' (Code.java:8) advised by before advice from 'X' (Code.java:12)"/>
+       </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>