aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs/DeclareSoftDynamicPCDs.java
blob: 07dba20dc99c59381b069f1e67343b3a346d0700 (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
/*
 * From:
 *
 * https://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/aspectj-home/doc/progguide/semantics-declare.html#d0e6499
 *
 * Pointcuts that appear inside of declare forms have certain restrictions.
 * Like other pointcuts, these pick out join points, but they do so in a
 * way that is statically determinable.
 *
 * Consequently, such pointcuts may not include, directly or indirectly
 * (through user-defined pointcut declarations) pointcuts that discriminate
 * based on dynamic (runtime) context. Therefore, such pointcuts may not be
 * defined in terms of
 *
 * cflow
 * cflowbelow
 * this
 * target
 * args
 * if
 *
 * all of which can discriminate on runtime information.
 */

public aspect DeclareSoftDynamicPCDs {

	declare soft : MyException:if(true) ;
	pointcut p(): if(false);
	declare soft : MyException: p() ;

	declare soft : MyException:cflow(execution(* main(..)));
	pointcut p2(): cflow(execution(* main(..)));
	declare soft : MyException:p2();

	declare soft : MyException:cflowbelow(execution(* main(..)));
	pointcut p3(): cflowbelow(execution(* main(..)));
	declare soft : MyException:p3();

	declare soft : MyException: this(Object);
	pointcut p4(): this(Object);
	declare soft : MyException:p4();

	declare soft : MyException:target(Object);
	pointcut p5(): target(Object);
	declare soft : MyException:p5();

	declare soft : MyException:args(Object);
	pointcut p6(): args(Object);
	declare soft : MyException:p6();

	class MyException extends Exception {
	}

    public static void main(String[] args) {
	    System.err.println("In main!");
    }

}