summaryrefslogtreecommitdiffstats
path: root/tests/features152
diff options
context:
space:
mode:
authoraclement <aclement>2006-08-01 12:40:31 +0000
committeraclement <aclement>2006-08-01 12:40:31 +0000
commitf4289cd1511ef1977fecd10cb1949c78dfbb9e9c (patch)
treedef310c140760ae7fb8d9776042a39480c518eec /tests/features152
parentc6b1c7c63fd4f4d2aa39cd7be2301d849c720b27 (diff)
downloadaspectj-f4289cd1511ef1977fecd10cb1949c78dfbb9e9c.tar.gz
aspectj-f4289cd1511ef1977fecd10cb1949c78dfbb9e9c.zip
synchronization pointcut problem (see Fourteen.java for info)
Diffstat (limited to 'tests/features152')
-rw-r--r--tests/features152/synchronization/transformed/Fourteen.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/features152/synchronization/transformed/Fourteen.java b/tests/features152/synchronization/transformed/Fourteen.java
new file mode 100644
index 000000000..62a339826
--- /dev/null
+++ b/tests/features152/synchronization/transformed/Fourteen.java
@@ -0,0 +1,46 @@
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.lang.reflect.*;
+
+/**
+ * We had a bug where if Xjoinpoints:synchronized was ON and yet no pointcuts used lock()/unlock() *and*
+ * a synchronized method was woven, then we got things wrong. We removed the synchronized modifier but
+ * never inserted the required monitorenter/exit block.
+ */
+public aspect Fourteen {
+
+ public static void main(String[] args) throws Exception {
+ Class c = Class.forName("Fourteen");
+ Method m = c.getMethod("b",null);
+ if (!Modifier.isSynchronized(m.getModifiers()))
+ throw new RuntimeException("Method b() should still be synchronized");
+ }
+
+ before(): call(* println(..)) {}
+
+ // ... that does something ...
+ public synchronized void b() {
+ System.out.println("hello");
+ }
+
+ // ... that includes try/catch ...
+ public synchronized void c() {
+ try {
+ File f = new File("fred");
+ FileInputStream fis = new FileInputStream(f);
+ } catch (IOException ioe) {
+ System.out.println("bang");
+ }
+ }
+
+ // ... with nested synchronized blocks ...
+ public synchronized void e() {
+ System.out.println("hello");
+ synchronized (new String()) {
+ System.out.println("other");
+ }
+ }
+
+}
+