aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs150/pr119749.aj
blob: dc3cc4bb5333b07a77c1b46f1d2b7c511f4de670 (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
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.aspectj.lang.JoinPoint;

public aspect pr119749 {
        // not inherited
        @Retention(RetentionPolicy.RUNTIME)
        @Target(ElementType.METHOD)     
        @interface Me{}

        static class C {
                @Me()
                void m() throws Exception {}
        }
        
        static class D extends C{
                void m() {}
        }
        
        static class E {
                D d(){return null;}
                C c(){return null;}
                static aspect A {
                        declare warning: execution(C E.*()) : "C E.*()";  //L26
                        declare warning: execution(D E.*()) : "D E.*()";  // L25
                }
        }
        
        public static void main(String[] args) {
                C c = new C();
                D d = new D();
                C cd = d;
                try {c.m();} catch (Exception e) {}
                try {cd.m();} catch (Exception e) {}
                d.m();
        }
        
        static aspect A {
                static void log(JoinPoint jp, Object o) {
                        System.out.println("" + jp + ": " + o);
                }
                pointcut scope() : within(pr119749);
                pointcut execMe() :execution(@Me void m()) && scope();  // L17
                pointcut execEx() :execution(void m() throws Exception) && scope(); // L17
                pointcut execAnyEx() :execution(* *(..) throws Exception) && scope(); // L17
                pointcut callEx() :call(void m() throws Exception) && scope(); // L37,38
                declare warning : execMe() : "aa @Me void m()";
                declare warning : execEx() : "aa void m() throws Exception";
                declare warning : execAnyEx() : "aa * *(..) throws Exception";
                declare warning : callEx() : "aa call void m() throws Exception";
                before(Me me) : @annotation(me) && execMe() {
                        log(thisJoinPoint, "execMe[" + me + "]");
                }
                before() : execEx() {
                        log(thisJoinPoint, "execEx");
                }
        }
}