blob: ed5376a79b2c66b9629fb7b5380d3fe60b068191 (
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
|
import org.aspectj.lang.reflect.*;
aspect TJPAspect {
before(): withincode(void ThisJoinPointLock.nonStaticMethod()) {
if (thisJoinPoint.getSignature() instanceof LockSignature) {
System.err.println("match.toString(): "+thisJoinPoint.toString());
System.err.println("match.toShortString(): "+thisJoinPoint.toShortString());
System.err.println("match.toLongString(): "+thisJoinPoint.toLongString());
}
// SHORT => shorttypenames, no args, no throws, no modifiers, short type names
// MIDDLE=> args included
// LONG => modifiers included
}
// before(): withincode(void ThisJoinPointLock.nonStaticMethod()) {
// if (thisJoinPoint.getSignature() instanceof MethodSignature) {
// System.err.println("match.toString(): "+thisJoinPoint.toString());
// System.err.println("match.toShortString(): "+thisJoinPoint.toShortString());
// System.err.println("match.toLongString(): "+thisJoinPoint.toLongString());
// }
//
// // SHORT => shorttypenames, no args, no throws, no modifiers, short type names
// // MIDDLE=> args included
// // LONG => modifiers included
// }
}
public class ThisJoinPointLock {
public static void main(String[] args) {
ThisJoinPointLock b = new ThisJoinPointLock();
b.nonStaticMethod();
b.staticMethod();
}
public void nonStaticMethod() {
synchronized (this) {
staticMethod();
}
}
public void staticMethod() {
synchronized (ThisJoinPointLock.class) {
}
}
}
|