blob: a1ab48eff883cc30f3b9ba23d3d4adfb4a7a4837 (
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
|
import org.aspectj.testing.Tester;
import org.aspectj.lang.*;
/** @testcase PR#658 simple call join point tests for JoinPoint SourceLocation context */
public class SourceLocationCall {
public static void main(String[] args) {
new SourceLocationCall().maincall();
}
public void maincall(){}
}
aspect Tracing {
static void check(String label, JoinPoint jp, JoinPoint.StaticPart sp) {
// System.err.println("checking " + label + " " + jp + " " + sp
// + " - " + jp.getSourceLocation()
// + " - " + sp.getSourceLocation() );
if (null == jp) {
Tester.check(false, "null JoinPoint@" + label);
} else {
Tester.check(null != jp.getSourceLocation(),
"null jp source location@" + label);
}
if (null == sp) {
Tester.check(false, "null JoinPoint.StaticPart@"+label);
} else {
Tester.check(null != sp.getSourceLocation(),
"null sp source location@" + label);
}
}
pointcut trace1()
: call(void SourceLocationCall.maincall(..));
// ok
//: within(SourceLocationCall) ;
//: cflow(execution(void SourceLocationCall.main(String[]))) && !within(Tracing) ;
//: within(SourceLocationCall) && call(* *(..));
//: execution(* SourceLocationCall.*(..));
//: call(void SourceLocationCall.main*(..)) && within(*);
// fail
//: call(void SourceLocationCall.main*(..));
//: call(* SourceLocationCall.*(..));
//: call(void SourceLocationCall.*(..));
// same result for static calls and instance calls
// same result for before and after
before() : trace1() {
check("before() : trace1()", thisJoinPoint, thisJoinPointStaticPart);
}
after() : trace1() {
check("after() : trace1()", thisJoinPoint, thisJoinPointStaticPart);
}
before(): call(void SourceLocationCall.main(..)) {
Tester.check(thisJoinPoint.getSourceLocation() == null, "main call");
Tester.check(thisJoinPoint.getThis() == null, "main call");
}
}
|