summaryrefslogtreecommitdiffstats
path: root/tests/new/StaticInitName.java
blob: 657bd2ebb6dbc55a46ed71d8e89ab686d3701cd1 (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
40
41
42
43
44
45
46
47
import org.aspectj.testing.Tester;
import java.util.*;

/** @testcase PR#771 static initializer member name */
public class StaticInitName {

    public static void main(String[] args) {
        Tester.expectEvent("C");
        Tester.event(""+C.class.getName());
        Tester.expectEvent("D");
        Tester.event(""+D.class.getName());
        Tester.checkAllEvents();
    }
}

class C {
    static int i = 1;
}

class D {
    static int i;
    static {
        i = 2;
    }
}

aspect A {
    static {
        Tester.expectEvent("before");
        Tester.expectEvent("before-D");
    }

    before() : within(C) && !set(* *) {
        Tester.event("before");
        String memberName = thisJoinPoint.getSignature().getName();
        Tester.check("<clinit>".equals(memberName),
                     "\"<clinit>\".equals(\"" + memberName + "\")");
    }

    before() : within(D) && !set(* *) {
        Tester.event("before-D");
        String memberName = thisJoinPoint.getSignature().getName();
        Tester.check("<clinit>".equals(memberName),
                     "\"<clinit>\".equals(\"" + memberName + "\")");
    }
}