summaryrefslogtreecommitdiffstats
path: root/tests/bugs161/pr203367/CantMatchOnInterfaceIntroducedToGenericClass.java
blob: 57414001cdd8593cff4e3244a7b10704d7f18a5f (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
package bug;  // I used a "bug" package under the "src" source folder.

public aspect CantMatchOnInterfaceIntroducedToGenericClass {
        public static interface Marker {}
        public static class NonGenericClass {
                public void doit(String msg) {
                        System.out.println("doit(): msg = "+msg);
                }
        }
        public static class GenericClass<T> {
                public void doit(T t) {
                        System.out.println("doit<T>(): t = "+t);
                }
        }

        declare parents: NonGenericClass implements Marker;
        declare parents: GenericClass    implements Marker;

        pointcut nonGenericCall(): call (void NonGenericClass.doit(..));
        pointcut genericCall():    call (void GenericClass.doit(..));
        pointcut markerCall():     call (void Marker+.doit(..));

        private static int mCount  = 0;
        
        before(): nonGenericCall() {
                System.out.println("nonGenericCall advice hit");
        }
        before(): genericCall() {
                System.out.println("genericCall advice hit");
        }
        before(): markerCall() {
        		mCount++;
                System.out.println("markerCall advice hit");
        }

        public static void main(String args[]) {
                new NonGenericClass().doit("message1");
                new GenericClass<Integer>().doit(new Integer(2));
                if (mCount!=2) {
                	throw new RuntimeException("Did not hit marker+ advice twice!");
                }
        }
}