]> source.dussan.org Git - aspectj.git/commitdiff
testcode for call and decp LTW 133770
authoraclement <aclement>
Mon, 14 Aug 2006 13:26:04 +0000 (13:26 +0000)
committeraclement <aclement>
Mon, 14 Aug 2006 13:26:04 +0000 (13:26 +0000)
33 files changed:
tests/ltw/callMunging/A.java [new file with mode: 0644]
tests/ltw/callMunging/B.java [new file with mode: 0644]
tests/ltw/callMunging/Main.java [new file with mode: 0644]
tests/ltw/callMunging/T.java [new file with mode: 0644]
tests/ltw/callMunging/X.java [new file with mode: 0644]
tests/ltw/callMunging/aop.xml [new file with mode: 0644]
tests/ltw/callMunging/case1/A.java [new file with mode: 0644]
tests/ltw/callMunging/case1/Main.java [new file with mode: 0644]
tests/ltw/callMunging/case1/T.java [new file with mode: 0644]
tests/ltw/callMunging/case1/X.java [new file with mode: 0644]
tests/ltw/callMunging/case1/aop.xml [new file with mode: 0644]
tests/ltw/callMunging/case1/readme.txt [new file with mode: 0644]
tests/ltw/callMunging/case2/A.java [new file with mode: 0644]
tests/ltw/callMunging/case2/Main.java [new file with mode: 0644]
tests/ltw/callMunging/case2/MarkerAnnotation.java [new file with mode: 0644]
tests/ltw/callMunging/case2/T.java [new file with mode: 0644]
tests/ltw/callMunging/case2/X.java [new file with mode: 0644]
tests/ltw/callMunging/case2/aop.xml [new file with mode: 0644]
tests/ltw/callMunging/case2/readme.txt [new file with mode: 0644]
tests/ltw/callMunging/case3/A.java [new file with mode: 0644]
tests/ltw/callMunging/case3/Main.java [new file with mode: 0644]
tests/ltw/callMunging/case3/S.java [new file with mode: 0644]
tests/ltw/callMunging/case3/T.java [new file with mode: 0644]
tests/ltw/callMunging/case3/X.java [new file with mode: 0644]
tests/ltw/callMunging/case3/aop.xml [new file with mode: 0644]
tests/ltw/callMunging/case3/readme.txt [new file with mode: 0644]
tests/ltw/hier/aop-single.xml [new file with mode: 0644]
tests/ltw/hier/child/Advisor.aj [new file with mode: 0644]
tests/ltw/hier/child/Executor.aj [new file with mode: 0644]
tests/ltw/hier/null-aop.xml [new file with mode: 0644]
tests/ltw/hier/top/SimpleMain.aj [new file with mode: 0644]
tests/ltw/hier/util/A.aj [new file with mode: 0644]
tests/ltw/hier/util/T.aj [new file with mode: 0644]

diff --git a/tests/ltw/callMunging/A.java b/tests/ltw/callMunging/A.java
new file mode 100644 (file)
index 0000000..3c15ddb
--- /dev/null
@@ -0,0 +1,7 @@
+public class A {
+  S s = new S();
+  public void method() {
+       System.out.println("A.method() running");
+    s.m1();
+  }
+}
diff --git a/tests/ltw/callMunging/B.java b/tests/ltw/callMunging/B.java
new file mode 100644 (file)
index 0000000..80bdb9c
--- /dev/null
@@ -0,0 +1,7 @@
+public class B {
+  T t = new T();
+  public void method() {
+       System.out.println("B.method() running");
+    t.m2();
+  }
+}
diff --git a/tests/ltw/callMunging/Main.java b/tests/ltw/callMunging/Main.java
new file mode 100644 (file)
index 0000000..94e395e
--- /dev/null
@@ -0,0 +1,21 @@
+import java.lang.reflect.Method;
+
+public class Main {
+
+  public static void main(String []argv) {
+         try {
+                 System.out.println("into:main");
+                 Class clazzA = Class.forName("A");
+                 Method clazzAMethod = clazzA.getMethod("method",null);
+                 clazzAMethod.invoke(clazzA.newInstance(),null);
+                 
+                 Class clazzB= Class.forName("B");
+                 Method clazzBMethod = clazzB.getMethod("method",null);
+                 clazzBMethod.invoke(clazzB.newInstance(),null);
+                 System.out.println("leave:main");
+         } catch (Throwable t) {
+                 t.printStackTrace();
+         }
+  }
+  
+}
diff --git a/tests/ltw/callMunging/T.java b/tests/ltw/callMunging/T.java
new file mode 100644 (file)
index 0000000..1a9a84a
--- /dev/null
@@ -0,0 +1,6 @@
+public class T {
+
+  public void m1() {System.out.println("T.m1() running");}
+  public void m2() {System.out.println("T.m2() running");}
+
+}
diff --git a/tests/ltw/callMunging/X.java b/tests/ltw/callMunging/X.java
new file mode 100644 (file)
index 0000000..836aa7b
--- /dev/null
@@ -0,0 +1,9 @@
+import java.io.Serializable;
+
+public aspect X {
+  declare parents: T implements Serializable;
+
+  before(): call(* Serializable+.m*(..)) {
+        System.out.println("advice running");
+  }
+}
diff --git a/tests/ltw/callMunging/aop.xml b/tests/ltw/callMunging/aop.xml
new file mode 100644 (file)
index 0000000..3211178
--- /dev/null
@@ -0,0 +1,7 @@
+<aspectj>
+<weaver options="-showWeaveInfo -verbose"/>
+<aspects>
+<aspect name="X"/>
+</aspects>
+</aspectj>
+
diff --git a/tests/ltw/callMunging/case1/A.java b/tests/ltw/callMunging/case1/A.java
new file mode 100644 (file)
index 0000000..23950c6
--- /dev/null
@@ -0,0 +1,7 @@
+public class A {
+  T t = new T();
+  public void method() {
+       System.out.println("A.method() running");
+    t.m1();
+  }
+}
diff --git a/tests/ltw/callMunging/case1/Main.java b/tests/ltw/callMunging/case1/Main.java
new file mode 100644 (file)
index 0000000..8466ce9
--- /dev/null
@@ -0,0 +1,17 @@
+import java.lang.reflect.Method;
+
+public class Main {
+
+  public static void main(String []argv) {
+         try {
+                 System.out.println("into:main");
+                 Class clazzA = Class.forName("A");
+                 Method clazzAMethod = clazzA.getMethod("method",null);
+                 clazzAMethod.invoke(clazzA.newInstance(),null);
+                 System.out.println("leave:main");
+         } catch (Throwable t) {
+                 t.printStackTrace();
+         }
+  }
+  
+}
diff --git a/tests/ltw/callMunging/case1/T.java b/tests/ltw/callMunging/case1/T.java
new file mode 100644 (file)
index 0000000..9e177ba
--- /dev/null
@@ -0,0 +1,3 @@
+public class T {
+  public void m1() {System.out.println("T.m1() running");}
+}
diff --git a/tests/ltw/callMunging/case1/X.java b/tests/ltw/callMunging/case1/X.java
new file mode 100644 (file)
index 0000000..836aa7b
--- /dev/null
@@ -0,0 +1,9 @@
+import java.io.Serializable;
+
+public aspect X {
+  declare parents: T implements Serializable;
+
+  before(): call(* Serializable+.m*(..)) {
+        System.out.println("advice running");
+  }
+}
diff --git a/tests/ltw/callMunging/case1/aop.xml b/tests/ltw/callMunging/case1/aop.xml
new file mode 100644 (file)
index 0000000..3211178
--- /dev/null
@@ -0,0 +1,7 @@
+<aspectj>
+<weaver options="-showWeaveInfo -verbose"/>
+<aspects>
+<aspect name="X"/>
+</aspects>
+</aspectj>
+
diff --git a/tests/ltw/callMunging/case1/readme.txt b/tests/ltw/callMunging/case1/readme.txt
new file mode 100644 (file)
index 0000000..c3c00dd
--- /dev/null
@@ -0,0 +1 @@
+Basic case, where type T needs munging with a declare parents before the join point in A.method() are matched.
\ No newline at end of file
diff --git a/tests/ltw/callMunging/case2/A.java b/tests/ltw/callMunging/case2/A.java
new file mode 100644 (file)
index 0000000..23950c6
--- /dev/null
@@ -0,0 +1,7 @@
+public class A {
+  T t = new T();
+  public void method() {
+       System.out.println("A.method() running");
+    t.m1();
+  }
+}
diff --git a/tests/ltw/callMunging/case2/Main.java b/tests/ltw/callMunging/case2/Main.java
new file mode 100644 (file)
index 0000000..8466ce9
--- /dev/null
@@ -0,0 +1,17 @@
+import java.lang.reflect.Method;
+
+public class Main {
+
+  public static void main(String []argv) {
+         try {
+                 System.out.println("into:main");
+                 Class clazzA = Class.forName("A");
+                 Method clazzAMethod = clazzA.getMethod("method",null);
+                 clazzAMethod.invoke(clazzA.newInstance(),null);
+                 System.out.println("leave:main");
+         } catch (Throwable t) {
+                 t.printStackTrace();
+         }
+  }
+  
+}
diff --git a/tests/ltw/callMunging/case2/MarkerAnnotation.java b/tests/ltw/callMunging/case2/MarkerAnnotation.java
new file mode 100644 (file)
index 0000000..f580bbe
--- /dev/null
@@ -0,0 +1,3 @@
+import java.lang.annotation.*;
+
+public @interface MarkerAnnotation {}
\ No newline at end of file
diff --git a/tests/ltw/callMunging/case2/T.java b/tests/ltw/callMunging/case2/T.java
new file mode 100644 (file)
index 0000000..9e177ba
--- /dev/null
@@ -0,0 +1,3 @@
+public class T {
+  public void m1() {System.out.println("T.m1() running");}
+}
diff --git a/tests/ltw/callMunging/case2/X.java b/tests/ltw/callMunging/case2/X.java
new file mode 100644 (file)
index 0000000..0be7aa1
--- /dev/null
@@ -0,0 +1,9 @@
+import java.io.Serializable;
+
+public aspect X {
+  declare @type: T: @MarkerAnnotation;
+
+  before(): call(* (@MarkerAnnotation *).m*(..)) {
+        System.out.println("advice running");
+  }
+}
diff --git a/tests/ltw/callMunging/case2/aop.xml b/tests/ltw/callMunging/case2/aop.xml
new file mode 100644 (file)
index 0000000..3211178
--- /dev/null
@@ -0,0 +1,7 @@
+<aspectj>
+<weaver options="-showWeaveInfo -verbose"/>
+<aspects>
+<aspect name="X"/>
+</aspects>
+</aspectj>
+
diff --git a/tests/ltw/callMunging/case2/readme.txt b/tests/ltw/callMunging/case2/readme.txt
new file mode 100644 (file)
index 0000000..5af1c9a
--- /dev/null
@@ -0,0 +1 @@
+Now type T needs munging with a declare annotation 
\ No newline at end of file
diff --git a/tests/ltw/callMunging/case3/A.java b/tests/ltw/callMunging/case3/A.java
new file mode 100644 (file)
index 0000000..3c15ddb
--- /dev/null
@@ -0,0 +1,7 @@
+public class A {
+  S s = new S();
+  public void method() {
+       System.out.println("A.method() running");
+    s.m1();
+  }
+}
diff --git a/tests/ltw/callMunging/case3/Main.java b/tests/ltw/callMunging/case3/Main.java
new file mode 100644 (file)
index 0000000..8466ce9
--- /dev/null
@@ -0,0 +1,17 @@
+import java.lang.reflect.Method;
+
+public class Main {
+
+  public static void main(String []argv) {
+         try {
+                 System.out.println("into:main");
+                 Class clazzA = Class.forName("A");
+                 Method clazzAMethod = clazzA.getMethod("method",null);
+                 clazzAMethod.invoke(clazzA.newInstance(),null);
+                 System.out.println("leave:main");
+         } catch (Throwable t) {
+                 t.printStackTrace();
+         }
+  }
+  
+}
diff --git a/tests/ltw/callMunging/case3/S.java b/tests/ltw/callMunging/case3/S.java
new file mode 100644 (file)
index 0000000..55cd6c5
--- /dev/null
@@ -0,0 +1,2 @@
+public class S extends T {
+}
diff --git a/tests/ltw/callMunging/case3/T.java b/tests/ltw/callMunging/case3/T.java
new file mode 100644 (file)
index 0000000..9e177ba
--- /dev/null
@@ -0,0 +1,3 @@
+public class T {
+  public void m1() {System.out.println("T.m1() running");}
+}
diff --git a/tests/ltw/callMunging/case3/X.java b/tests/ltw/callMunging/case3/X.java
new file mode 100644 (file)
index 0000000..836aa7b
--- /dev/null
@@ -0,0 +1,9 @@
+import java.io.Serializable;
+
+public aspect X {
+  declare parents: T implements Serializable;
+
+  before(): call(* Serializable+.m*(..)) {
+        System.out.println("advice running");
+  }
+}
diff --git a/tests/ltw/callMunging/case3/aop.xml b/tests/ltw/callMunging/case3/aop.xml
new file mode 100644 (file)
index 0000000..3211178
--- /dev/null
@@ -0,0 +1,7 @@
+<aspectj>
+<weaver options="-showWeaveInfo -verbose"/>
+<aspects>
+<aspect name="X"/>
+</aspects>
+</aspectj>
+
diff --git a/tests/ltw/callMunging/case3/readme.txt b/tests/ltw/callMunging/case3/readme.txt
new file mode 100644 (file)
index 0000000..b23a4e2
--- /dev/null
@@ -0,0 +1 @@
+declare parents, but this time there is an extra layer in the hierarchy, A calls S but S extends T and T is decp targeted
\ No newline at end of file
diff --git a/tests/ltw/hier/aop-single.xml b/tests/ltw/hier/aop-single.xml
new file mode 100644 (file)
index 0000000..9546f8c
--- /dev/null
@@ -0,0 +1,7 @@
+<aspectj>
+  <weaver options="-showWeaveInfo"/>
+  <aspects>
+    <aspect name="child.Advisor"/>
+  </aspects>
+</aspectj>
+
diff --git a/tests/ltw/hier/child/Advisor.aj b/tests/ltw/hier/child/Advisor.aj
new file mode 100644 (file)
index 0000000..d7b6b33
--- /dev/null
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ron Bodkin
+ */
+package child;
+
+import util.A;
+import util.T;
+
+aspect Advisor {
+       declare parents: A* implements T;
+
+       before() : call(* T+.*(..)) {
+               System.out.println("T call");
+       }
+}
diff --git a/tests/ltw/hier/child/Executor.aj b/tests/ltw/hier/child/Executor.aj
new file mode 100644 (file)
index 0000000..74a90a0
--- /dev/null
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ron Bodkin
+ */
+package child;
+
+import util.A;
+
+public class Executor implements Runnable {
+   public void run() {
+      new A().foo();
+   }
+}
diff --git a/tests/ltw/hier/null-aop.xml b/tests/ltw/hier/null-aop.xml
new file mode 100644 (file)
index 0000000..6ca1f4a
--- /dev/null
@@ -0,0 +1,2 @@
+<!-- empty aop.xml file. Used to turn on load-time weaving with no aspects defined at top-level -->
+<aspectj/>
diff --git a/tests/ltw/hier/top/SimpleMain.aj b/tests/ltw/hier/top/SimpleMain.aj
new file mode 100644 (file)
index 0000000..1355fb4
--- /dev/null
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ron Bodkin
+ */
+package top;
+
+public class SimpleMain {
+   public static void main(String args[]) throws Exception {
+      new child.Executor().run();
+   }
+}
diff --git a/tests/ltw/hier/util/A.aj b/tests/ltw/hier/util/A.aj
new file mode 100644 (file)
index 0000000..df695c0
--- /dev/null
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ron Bodkin
+ */
+package util;
+
+public class A {
+    public void foo() {}
+}
diff --git a/tests/ltw/hier/util/T.aj b/tests/ltw/hier/util/T.aj
new file mode 100644 (file)
index 0000000..f87f92d
--- /dev/null
@@ -0,0 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ron Bodkin
+ */
+package util;
+
+public interface T {}