blob: 5463a3215bb566a2d72c4d6faec89ff796ff6c83 (
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
|
// after advice and unlock
public aspect AfterUnlock {
after(Foo f): unlock() && this(f) {
System.err.println("after(Foo) unlock: advice running at "+thisJoinPoint.getSourceLocation());
}
after(): unlock() {
System.err.println("after() unlock: advice running at "+thisJoinPoint.getSourceLocation());
}
public static void main(String[] args) {
Foo aFoo = new Foo();
aFoo.staticM();
aFoo.nonstaticM();
}
static class Foo {
public void nonstaticM() {
synchronized (this) {
System.err.println("non-static method running");
}
}
public static void staticM() {
synchronized (String.class) {
System.err.println("static method running");
}
}
}
}
|