summaryrefslogtreecommitdiffstats
path: root/tests/features152/synchronization/BeforeLock.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/features152/synchronization/BeforeLock.java')
-rw-r--r--tests/features152/synchronization/BeforeLock.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/features152/synchronization/BeforeLock.java b/tests/features152/synchronization/BeforeLock.java
new file mode 100644
index 000000000..334137ad1
--- /dev/null
+++ b/tests/features152/synchronization/BeforeLock.java
@@ -0,0 +1,31 @@
+// before advice and lock
+
+public aspect BeforeLock {
+
+ before(Foo f): lock() && this(f) {
+ System.err.println("before(Foo) lock: advice running at "+thisJoinPoint.getSourceLocation());
+ }
+
+ before(): lock() {
+ System.err.println("before() lock: 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");
+ }
+ }
+ }
+} \ No newline at end of file