]> source.dussan.org Git - aspectj.git/commitdiff
tests and fix for pr114054 (erroneous handling of negation in per-object perclauses)
authoracolyer <acolyer>
Wed, 23 Nov 2005 16:20:19 +0000 (16:20 +0000)
committeracolyer <acolyer>
Wed, 23 Nov 2005 16:20:19 +0000 (16:20 +0000)
tests/bugs150/Pr114054.aj [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
weaver/src/org/aspectj/weaver/patterns/PerThisOrTargetPointcutVisitor.java

diff --git a/tests/bugs150/Pr114054.aj b/tests/bugs150/Pr114054.aj
new file mode 100644 (file)
index 0000000..3f776df
--- /dev/null
@@ -0,0 +1,30 @@
+public class Pr114054 {
+       public static boolean passed;
+       public static void main(String[] args) {
+               SampleSeries me = new SampleSeries();
+               me.okSeries();
+               me.open();
+               me.close();
+               if (!passed) {
+                       throw new Error("failed to advise...");
+               }
+       }
+       static class SampleSeries {
+               void open() {}
+               void close() {}
+               void okSeries() {open(); close();}
+       }
+       static aspect AAAA 
+       // comment this out, and !call(...) works
+       pertarget(tracked())
+       {
+           protected final pointcut tracked() : 
+                       call(void SampleSeries.*()) 
+                       // comment this out, and pertarget works...
+                       && !call(void SampleSeries.*Series())
+                       ;
+               before() : tracked() {
+                       Pr114054.passed = true;
+               }               
+       }
+}
\ No newline at end of file
index be703cb0345362a136d7897958384a5db0a81745..41960b5ae7a739f5f4a72957392e54b3c3c8c33f 100644 (file)
@@ -739,6 +739,10 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
          runTest("returning(Object) binding");
   }
   
+  public void testPerTargetAndNegation() {
+         runTest("pertarget and negated pointcut");
+  }
+  
   /*
    * Load-time weaving bugs
    */
index 5b072abf7a25c4621e75fdba5d8623901fb38dc1..19a8c0f2fcc356f623b505fc4930d2b9243a2790 100644 (file)
       </run>
     </ajc-test>
     
+    <ajc-test dir="bugs150" pr="114054" title="pertarget and negated pointcut">
+     <compile files="Pr114054.aj" options=""/>
+     <run class="Pr114054"/>
+    </ajc-test>
+    
     <ajc-test dir="bugs150" pr="104220" title="adviceexecution join point toString forms">
       <compile files="Pr104220.aj"/>
       <run class="Pr104220">
index da8271721214fe57dec8b40bb27feb7665e071cc..daaf2d5e14651efd3b0b3e6e058ebdc2b04bd5fd 100644 (file)
@@ -113,11 +113,14 @@ public class PerThisOrTargetPointcutVisitor extends IdentityPointcutVisitor {
     }
 
     public Object visit(NotPointcut node, Object data) {
-        TypePattern negated = getPerTypePointcut(node.getNegatedPointcut());
-        if (MAYBE.equals(negated)) {
-            return MAYBE;
-        }
-        return new NotTypePattern(negated);
+//        TypePattern negated = getPerTypePointcut(node.getNegatedPointcut());
+//        if (MAYBE.equals(negated)) {
+//            return MAYBE;
+//        }
+//        return new NotTypePattern(negated);
+           // AMC - the only safe thing to return here is maybe...
+               // see for example pr114054
+       return MAYBE;
     }
 
     public Object visit(ThisOrTargetAnnotationPointcut node, Object data) {