aboutsummaryrefslogtreecommitdiffstats
path: root/tests/new/AfterAdviceOnConstructorsOnTheWrongType.java
blob: 21ab6cb6bbda2f62de2ba055d6a572c2605817c6 (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
import org.aspectj.testing.Tester; 
public class AfterAdviceOnConstructorsOnTheWrongType {
    public static void main(String[] args) {
        new AfterAdviceOnConstructorsOnTheWrongType().realMain(args);
    }
    public void realMain(String[] args) {
        new C().c();
        new D().d();
        Tester.checkAllEvents();
    }
    static {
        Tester.clearEvents();
        // new(..) for just class
        Tester.expectEventsInString("after-c,c,after-d,d");
    }
}

interface I {}
class C implements I { public void c() { Tester.event("c"); } }
class D implements I { public void d() { Tester.event("d"); } }

aspect A {
    after(C c): target(c) && execution(new(..)) {
        Tester.event("after-c");
    }
    after(D d): target(d) && execution(new(..)) {
        Tester.event("after-d");
    }
}