blob: 3431da405c90b30f3a0cba063bf4b1f9948e322c (
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
|
import org.aspectj.testing.Tester;
public class Driver {
public static boolean classStaticInitRan, classInitRan;
public static boolean aspectStaticInitRan, aspectInitRan;
public static void main(String[] args) { test(); }
public static void test() {
Class c = new Class();
Tester.check(classStaticInitRan, "ran class's static initializer");
Tester.check(classInitRan, "ran class's initializer");
Tester.check(aspectStaticInitRan, "ran aspect's static initializer");
Tester.check(aspectInitRan, "ran aspect's initializer");
}
}
class Class {
static {
Driver.classStaticInitRan = true;
}
{
Driver.classInitRan = true;
}
}
aspect Aspect pertarget(target(Class)) {
static {
Driver.aspectStaticInitRan = true;
}
// non-static initializer
{
Driver.aspectInitRan = true;
}
}
|