aboutsummaryrefslogtreecommitdiffstats
path: root/tests/features152/synchronization/AroundUnlock.java
blob: a4a3a91a85c40d2ba5442647a3f35f1a8e60a3b7 (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
// around advice and unlock

public aspect AroundUnlock {

	void around(Foo f): unlock() && args(f) {
		System.err.println("around(Foo) lock: advice running at "+thisJoinPoint.getSourceLocation());
		proceed(f);
	}
	
	void around(): unlock() {
		System.err.println("around() lock: advice running at "+thisJoinPoint.getSourceLocation());
		proceed();
	}
	
	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");
			}
		}
	}
}