aboutsummaryrefslogtreecommitdiffstats
path: root/tests/new/TryFinallyInAround.java
blob: b963eab0d07a872979f1c5395326714b5bff3f2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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");
        }
    }
}