summaryrefslogtreecommitdiffstats
path: root/tests/new/ConstructorExecInit.java
blob: e27fbc205b8e18adb19c873aa47a2f90bf05144c (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
import org.aspectj.testing.*;

/**
 * -usejavac mode: no error
 * not -usejavac mode: VerifyError
 */
public class ConstructorExecInit {
    public static void main(String[] args) {
        new ConstructorExecInit();
        Tester.checkAllEvents();
    }
    static {
        Tester.expectEvent("execution");
        Tester.expectEvent("initialization");
    }
}

/** @testcase after returning from initialization and after executing constructor */
aspect A {
    after (Object target) : execution(*.new(..)) && target(target) && !within(A) { 
        Tester.event("execution");
    }
    after () returning : initialization(new(..)) && !this(A) { 
        Tester.event("initialization");
    }
}