blob: 0ca1bbc209d253bb395c53e81b74d209948138ca (
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
|
abstract aspect GenericAspectPointcuts<S,T,E> {
/**
test declare warning with :
- KindedPointcut
all parts of Signature pattern
- HandlerPointcut
- ReferencePointcut
- WithincodePointcut
- WithinPointcut
- And
- Or
- Not
*/
pointcut kindedWithReturning() : execution(T *(..));
pointcut kindedWithDeclaring() : call(* S.*(..));
pointcut kindedWithParams() : execution(* *(T));
pointcut kindedWithThrows() : execution(* *(..) throws E);
pointcut p1() : execution(* T.*(..));
pointcut p2() : execution(S *(..));
pointcut p3() : set(S a);
pointcut p4() : get(* T.*);
pointcut p5() : within(S || T);
pointcut handlerPC() : handler(E);
declare warning : kindedWithReturning() : "kinded-returning-ok";
declare warning : kindedWithDeclaring() : "kinded-declaring-ok";
declare warning : kindedWithParams() : "kinded-params-ok";
declare warning : kindedWithThrows() : "kinded-throws-ok";
declare warning : p1() && p2() : "and-ok";
declare warning : p3() || p4() : "or-ok";
declare warning : staticinitialization(*) && !p5() : "not-ok";
declare warning : within(T) && staticinitialization(*) : "within-ok";
declare warning : withincode(S T.*(..)) : "withincode-ok";
}
aspect Sub extends GenericAspectPointcuts<A,B,Z> {
declare warning : handlerPC() : "handler-ok"; // also tests ref to super pointcut
}
class A {
void bar(B b) {
try {
t();
} catch( Z z) { System.out.println("z");}
}
void t() throws Z {}
}
class B {
A a = new A();
B newB() { return new B(); }
A newA() { return a; }
void foo() {
a.bar(this);
}
}
class Z extends Exception {}
|