diff options
Diffstat (limited to 'tests/features152/synchronization/LockingWithTJP.java')
-rw-r--r-- | tests/features152/synchronization/LockingWithTJP.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/features152/synchronization/LockingWithTJP.java b/tests/features152/synchronization/LockingWithTJP.java new file mode 100644 index 000000000..a07b567ce --- /dev/null +++ b/tests/features152/synchronization/LockingWithTJP.java @@ -0,0 +1,28 @@ +// obtaining the object being locked on + +public aspect LockingWithTJP { + + before(): lock() { + System.err.println("before() lock: advice running at "+thisJoinPoint.getSourceLocation()); + System.err.println("Locked on "+thisJoinPoint.getArgs()[0]); + } + + public static void main(String[] args) { + Foo aFoo = new Foo(); + aFoo.nonstaticM(); + aFoo.staticM(); + } + + 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"); + } + } + } +}
\ No newline at end of file |