aboutsummaryrefslogtreecommitdiffstats
path: root/tests/new/PerTargetAndVariablesWithNumbersInTheirNames.java
blob: 1f0ca54bf22346dfd9b3a25c83c80cc9aceb0143 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import org.aspectj.testing.*;

/**
 * PR#490
 * Came from a bug from Svan Macke:
 *
 * Here is another problem that occured when I changed
 * from aspectj0.8b3 to aspectj0.8b4. It seems that
 * (under a very special condition) aspectJ has problems
 * with the numbers that are appended to variable names
 * inside the generated advice code.
 * 
 * Here is the "special condition" where the error
 * occured. I know the discussion about 'of eachobject'
 * and I also know that in the following code it is
 * absolutely unnecessary to use 'of eachobject' (don't
 * ask me why I wrote such terrible code, I do not know
 * it myself), but however, I think it is correct aspectj
 * code and should therefore compile correctly.
 *
 * @since  2000.08.06
 * @author Jeff Palm
 * @report 408
 */
public class PerTargetAndVariablesWithNumbersInTheirNames {
    public static void main(String[] args) {
        new C();
        Tester.checkAllEvents();
    }
    static {
        Tester.expectEvent("Hello 1");
        Tester.expectEvent("World 2");
        Tester.expectEvent("Hello World around 1");
        Tester.expectEvent("Hello World around 2");
        Tester.expectEvent("Hello World around 3");
        Tester.expectEvent("Hello World around 4");
    }
}

class C
{
    public C()
    {
	doSomething("Hello", "World");
    }
    public void doSomething(String arg1, String arg2)
    {
        Tester.event(arg1 + " 1");
        Tester.event(arg2 + " 2");
    }
}

/*
 * A pertarget aspect.
 */
aspect A1 pertarget(target(C)) {
    void around(String arg1, String arg2):
        target(C) &&
        call(public void doSomething(String,String)) &&
        args(arg1, arg2) {
            Tester.event(arg1 + " " + arg2 + " around 1");
            proceed(arg1, arg2);
        }
}

/*
 * Another pertarget aspect.
 */
aspect A2 pertarget(target(C)) {
    void around(String arg1, String arg2):
        target(C) &&
        call(public void doSomething(String,String)) &&
        args(arg1, arg2) {
            Tester.event(arg1 + " " + arg2 + " around 2");
            proceed(arg1, arg2);
        }
}

/*
 * A 'static' aspect.
 */
aspect A3 {
    void around(String arg1, String arg2):
        target(C) &&
        call(public void doSomething(String,String)) &&
        args(arg1, arg2) {
            Tester.event(arg1 + " " + arg2 + " around 3");
            proceed(arg1, arg2);
        }
}

/*
 * Another 'static' aspect.
 */
aspect A4 {
    void around(String arg1, String arg2):
        target(C) &&
        call(public void doSomething(String,String)) &&
        args(arg1, arg2) {
            Tester.event(arg1 + " " + arg2 + " around 4");
            proceed(arg1, arg2);
        }
}