]> source.dussan.org Git - aspectj.git/commitdiff
@testcase try/finally in around advice (same as ...messy arounds?)
authorwisberg <wisberg>
Wed, 23 Apr 2003 00:32:49 +0000 (00:32 +0000)
committerwisberg <wisberg>
Wed, 23 Apr 2003 00:32:49 +0000 (00:32 +0000)
Works in current tree, but not in 1.1rc1

tests/ajcTests.xml
tests/new/TryFinallyInAround.java [new file with mode: 0644]

index 8785b0b8acda5f25f9fc07b480d9833feaad86ac..7bc3af75020bf88e3df01d8533e40f7ea490d2ab 100644 (file)
         </compile>
         <run class="cap.OptionList"/>
     </ajc-test>  
+
+    <ajc-test dir="new"
+      title="try/finally in around advice (same as ...messy arounds?)">
+        <compile files="TryFinallyInAround.java"/>
+        <run class="TryFinallyInAround"/>
+    </ajc-test>
     
 </suite>
diff --git a/tests/new/TryFinallyInAround.java b/tests/new/TryFinallyInAround.java
new file mode 100644 (file)
index 0000000..b963eab
--- /dev/null
@@ -0,0 +1,39 @@
+
+import org.aspectj.testing.Tester;
+
+// XXX broken in 1.1rc1, fixed in tree as of 4/22
+/** @testcase try/finally in around advice (same as ...messy arounds?) */
+public class TryFinallyInAround {
+    public static void main(String[] args) {
+        int i = new C().go();
+        Tester.check(2 == i, "expected 2 got " + i);
+    }
+}
+
+class C {
+    int i = 1;
+    int go() {
+        dowork();
+        return i;
+    }
+    void dowork() {
+        i++;
+    }
+}
+
+aspect A {
+    Object around() : 
+        within(C)       
+        && !cflow(within(A)) 
+        && !handler(*)
+        && !preinitialization(new(..)) // 1.1
+        && !initialization(new(..))
+        {
+            // no bug if reduced to proceed();
+        try {
+            return proceed();
+        } finally {
+            if (false) System.out.println("ok");
+        }
+    }
+}