aboutsummaryrefslogtreecommitdiffstats
path: root/tests/new/PR353c.java
blob: fe4a9e68591ba57d736c0aa5c605f164e59f2ae3 (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import org.aspectj.testing.*;
import java.util.*;

public class PR353c {

   public static void main(String[] args){
     new PR353c().go();
   }
   
   void go(){
       C c = new C(); c.f(); c.g();
       A a = new A(); a.f(); a.g();
       B b = new B(); b.f(); b.g();
       D d = new D(); d.f(); d.g();
       E e = new E(); e.f(); e.g();
   }
}

interface I { }

class C {
    void f() {}
    void g() {}
}

class A extends C {
    void f() {}
}

class B extends C {
    void f() {}
    void g() {}
}

class D extends C { }
class E extends C implements I { }

aspect AA extends AspectSupport {

    pointcut f(): receptions(void f());
    pointcut g(): receptions(void g());
    pointcut b(): f() || g();

    pointcut all(): b();
    pointcut notC(): b() && !instanceof(C);
    pointcut notD1(): b() && instanceof(C) && !instanceof(D);
    pointcut notD2(): b() && !instanceof(D) && instanceof(C);
    pointcut notI(): b() && !instanceof(I);
    pointcut notA1(): b() && instanceof(C) && !instanceof(A);
    pointcut notA2(): b() && !instanceof(A) && instanceof(C);
    pointcut notB1(): b() && instanceof(C) && !instanceof(B);
    pointcut notB2(): b() && !instanceof(B) && instanceof(C);
    pointcut notE1(): b() && instanceof(C) && !instanceof(E);
    pointcut notE2(): b() && !instanceof(E) && instanceof(C);



    static before(): all() { p("cabde", thisJoinPoint.className); }
    static before(): notC() { p("", thisJoinPoint.className); }
    static before(): notD1() { p("cabe", thisJoinPoint.className); }
    static before(): notD2() { p("cabe", thisJoinPoint.className); }
    static before(): notI() { p("cabd", thisJoinPoint.className); }
    static before(): notA1() { p("cbde", thisJoinPoint.className); }
    static before(): notA2() { p("cbde", thisJoinPoint.className); }
    static before(): notB1() { p("cade", thisJoinPoint.className); }
    static before(): notB2() { p("cade", thisJoinPoint.className); }
    static before(): notE1() { p("cadb", thisJoinPoint.className); }
    static before(): notE2() { p("cadb", thisJoinPoint.className); }

    pointcut _b():  receptions(* *());
    
    pointcut _all(): _b();
    pointcut _notC(): _b() && !instanceof(C);
    pointcut _notD1(): _b() && instanceof(C) && !instanceof(D);
    pointcut _notD2(): _b() && !instanceof(D) && instanceof(C);
    pointcut _notI(): _b() && !instanceof(I);
    pointcut _notA1(): _b() && instanceof(C) && !instanceof(A);
    pointcut _notA2(): _b() && !instanceof(A) && instanceof(C);
    pointcut _notB1(): _b() && instanceof(C) && !instanceof(B);
    pointcut _notB2(): _b() && !instanceof(B) && instanceof(C);
    pointcut _notE1(): _b() && instanceof(C) && !instanceof(E);
    pointcut _notE2(): _b() && !instanceof(E) && instanceof(C);   

    static before(): _all() { p("cabde", thisJoinPoint.className); }
    static before(): _notC() { p("", thisJoinPoint.className); }
    static before(): _notD1() { p("cabe", thisJoinPoint.className); }
    static before(): _notD2() { p("cabe", thisJoinPoint.className); }
    static before(): _notI() { p("cabd", thisJoinPoint.className); }
    static before(): _notA1() { p("cbde", thisJoinPoint.className); }
    static before(): _notA2() { p("cbde", thisJoinPoint.className); }
    static before(): _notB1() { p("cade", thisJoinPoint.className); }
    static before(): _notB2() { p("cade", thisJoinPoint.className); }
    static before(): _notE1() { p("cadb", thisJoinPoint.className); }
    static before(): _notE2() { p("cadb", thisJoinPoint.className); }    
}

class Verifier {
    void verify(Map map) {
        Iterator iter = map.keySet().iterator();
        while (iter.hasNext()) {
            String key = (iter.next() + "").toLowerCase();
            List list = (List) map.get(key);
            Iterator it = list.iterator();
            while (it.hasNext()) {
                Object onext = it.next();
                String next = (onext + "").toLowerCase();
                if (key.indexOf(next) == -1) {
                    Tester.check(false, next + " not found in " + key);
                } else {
                    it.remove();
                }
            }
            Tester.check(list.size() == 0, list + " contains classes excluded");
        }
    }
}
aspect AspectSupport {

    public static Map map = new HashMap();
    static {
        String[] ss = {

        };
        for (int i = 0; i < ss.length; i++) {
            map.put(ss[i], new Vector());
        }
    }

    static void p(String key, String str) {
        List list = (List) map.get(key);
        if (list == null) {
            list = new Vector();
        }
        list.add(str);
        map.put(key, list);
    }

    static List v(Object[] os) {
        List v = new Vector();
        for (int i = 0; i < os.length; i++) {
            v.add(os[i]);
        }
        return v;
    }
}