blob: 5d0db8c15948312bc75dd859b11b0327372ab60c (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
import org.aspectj.testing.Tester;
public class Driver {
public static void main(String[] args) { test(); }
public static void test() {
C1 c1 = new C1();
C11 c11 = new C11();
C111 c111 = new C111();
C12 c12 = new C12();
Cleaf1 cleaf1 = new Cleaf1();
Cleaf11 cleaf11 = new Cleaf11();
Cleaf111 cleaf111 = new Cleaf111();
Cleaf12 cleaf12 = new Cleaf12();
}
}
interface I1 { }
interface I11 extends I1 { }
interface I111 extends I11 { }
interface I12 extends I1 { }
class C1 implements I1 { C1(String s) {} }
class C11 implements I11 { }
class C111 implements I111 { }
class C12 implements I12 { }
class Cleaf1 extends C1 { }
class Cleaf11 extends C11 { }
class Cleaf111 extends C111 { }
class Cleaf12 extends C12 { }
// For this class structure: here is the "directly implements" relation
// C1 directly implements I1
// C11 directly implements I11
// C11 directly implements I1
// C111 directly implements I111
// C111 directly implements I11
// C111 directly implements I1
// C12 directly implements I12
// C12 directly implements I1
aspect A1 {
static int i1Count, c1Count, c1IntCount = 0;
// interface
before(): initialization(I1.new(..)) {
i1Count++;
}
C1.new() {
c1Count++;
}
C1.new(int x) {
c1IntCount++;
}
}
aspect Verify {
// In the current model, introduces on constructors !don't! work their way
// down the inheritance. With the given hierarchy, the number of
// invocations of the introduced constructors should match the
// numbers below.
after(): within(Driver) && execution(static void test(..)) {
Tester.checkEqual(A1.i1Count, 8, "A1.i1Count");
Tester.checkEqual(A1.c1Count, 2, "A1.c1Count");
Tester.checkEqual(A1.c1IntCount, 0, "A1.c1IntCount");
}
}
|