diff options
author | aclement <aclement> | 2006-05-24 07:15:42 +0000 |
---|---|---|
committer | aclement <aclement> | 2006-05-24 07:15:42 +0000 |
commit | b2247654a3b35eb26731fac20247fc3007612eab (patch) | |
tree | 3b3bc6d6e2833e1d62aaf4506b1e8e3f4d12f51d /tests/features152/synchronization/Basic4.java | |
parent | 917a3a70f5c09f16151200f13eb89283c4bb2abf (diff) | |
download | aspectj-b2247654a3b35eb26731fac20247fc3007612eab.tar.gz aspectj-b2247654a3b35eb26731fac20247fc3007612eab.zip |
synchronization joinpoints: testcode
Diffstat (limited to 'tests/features152/synchronization/Basic4.java')
-rw-r--r-- | tests/features152/synchronization/Basic4.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/features152/synchronization/Basic4.java b/tests/features152/synchronization/Basic4.java new file mode 100644 index 000000000..787f550a8 --- /dev/null +++ b/tests/features152/synchronization/Basic4.java @@ -0,0 +1,52 @@ +// Exploring synchronization + +aspect WithinAspect { + before(Object o ): within(Basic4) && args(o) { + if (thisJoinPoint.getSignature().toString().indexOf("lock(")!=-1) + System.err.println("Advice running at "+thisJoinPoint.getSignature()+ + " with args of type "+o.getClass()+" with value "+o); + } +} + +public class Basic4 { + public static void main(String[] args) { + Basic4 b = new Basic4(); + + b.methodWithSyncBlock1(); + b.staticMethodWithSyncBlock1(); + b.methodWithSyncBlock2(); + b.staticMethodWithSyncBlock2(); + } + + public void methodWithSyncBlock1() { + System.err.println("methodWithSyncBlock1"); + synchronized (this) { + } + } + + public void staticMethodWithSyncBlock1() { + System.err.println("staticMethodWithSyncBlock1"); + synchronized (Basic4.class) { + } + } + + public void methodWithSyncBlock2() { + System.err.println("methodWithSyncBlock2"); + synchronized (this) { + int i = 0; + while (i<100) { + i++; + } + } + } + + public void staticMethodWithSyncBlock2() { + System.err.println("staticMethodWithSyncBlock2"); + synchronized (Basic4.class) { + int i = 0; + while (i<100) { + i++; + } + } + } +} |