summaryrefslogtreecommitdiffstats
path: root/tests/base/test140/Driver.java
blob: db03998ae85ff8d46dc28cae62895ae2e54f7322 (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
import org.aspectj.testing.Tester;

// aspect inheritance and advice, introduction

public class Driver {
    public static void test() {
        C1 c1 = new C1();
        
        Tester.checkEqual(c1.foo(), "from A2", "sub-aspects");
        Tester.checkEqual(c1.bar(), 
                           "from A0 #2", 
                           "sub-aspects and position");

	// the around advice lexically in A1 runs twice, once for each concrete
	// sub-aspects.  putting advice on a concrete pointcut in an abstract
	// aspect will always have this odd behavior, and possibly should be illegal
        Tester.checkEqual(c1.getString(), 
                           ":A2:A1:A1:C1",
                           "multiple arounds");
    }

    public static void main(String[] args) { test(); }
}

class C1 {
    String getString() {
        return ":C1";
    }
}

abstract aspect A1 {
    String C1.foo() {
	return "from A1";
    }
    
    String C1.bar() {
	return "from A1";
    }

    String around(): 
            call(String C1.getString()) {
        return ":A1" + proceed();
    }
}

aspect A2 extends A1 {
    String C1.foo() {
	return "from A2";
    }

    String around(): 
            call(String C1.getString()) {
        return ":A2" + proceed();
    }
    
}

aspect A0 extends A1 {
    // multiple conflicting declarations in the same aspect are now an error
    //String C1.bar() {
    //	return "from A0 #1";
    //}
    
    String C1.bar() {
	return "from A0 #2";
    }
}