]> source.dussan.org Git - aspectj.git/commitdiff
194314: lvt tests
authoraclement <aclement>
Sat, 1 Nov 2008 17:23:54 +0000 (17:23 +0000)
committeraclement <aclement>
Sat, 1 Nov 2008 17:23:54 +0000 (17:23 +0000)
tests/bugs163/pr194314/IService.java [new file with mode: 0644]
tests/bugs163/pr194314/Main.java [new file with mode: 0644]
tests/bugs163/pr194314/Service.java [new file with mode: 0644]
tests/bugs163/pr194314/ServiceInterceptor.java [new file with mode: 0644]
tests/bugs163/pr194314/ServiceInterceptorCodeStyle.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java
tests/src/org/aspectj/systemtest/ajc163/ajc163.xml

diff --git a/tests/bugs163/pr194314/IService.java b/tests/bugs163/pr194314/IService.java
new file mode 100644 (file)
index 0000000..ed383d0
--- /dev/null
@@ -0,0 +1,4 @@
+
+public interface IService {
+    void method(long l) throws Exception;
+}
diff --git a/tests/bugs163/pr194314/Main.java b/tests/bugs163/pr194314/Main.java
new file mode 100644 (file)
index 0000000..f901076
--- /dev/null
@@ -0,0 +1,8 @@
+
+public class Main {
+
+    public static void main(String[] args) throws Exception {
+        IService service = new Service();
+        service.method(42L);
+    }
+}
diff --git a/tests/bugs163/pr194314/Service.java b/tests/bugs163/pr194314/Service.java
new file mode 100644 (file)
index 0000000..f3302fa
--- /dev/null
@@ -0,0 +1,7 @@
+
+public class Service implements IService {
+
+    public void method(long l) throws Exception {
+        System.err.println("Original impl of service method, arg " + l);
+    }
+}
diff --git a/tests/bugs163/pr194314/ServiceInterceptor.java b/tests/bugs163/pr194314/ServiceInterceptor.java
new file mode 100644 (file)
index 0000000..00bb779
--- /dev/null
@@ -0,0 +1,17 @@
+
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+
+@Aspect
+public class ServiceInterceptor {
+
+    @Around("execution(void test.Service.method(long))")
+    public void method(ProceedingJoinPoint pjp) throws Throwable {
+        Object[] args = pjp.getArgs();
+        long id = (Long) args[0];
+        System.out.println("in advice, arg = " + id + " (before proceed)");
+        pjp.proceed(pjp.getArgs());
+        System.out.println("in advice (after proceed)");
+    }
+}
diff --git a/tests/bugs163/pr194314/ServiceInterceptorCodeStyle.java b/tests/bugs163/pr194314/ServiceInterceptorCodeStyle.java
new file mode 100644 (file)
index 0000000..b08047d
--- /dev/null
@@ -0,0 +1,15 @@
+
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+
+public aspect ServiceInterceptorCodeStyle {
+
+    void around(): execution(void Service.method(long)) {
+        Object[] args = thisJoinPoint.getArgs();
+        long id = (Long) args[0];
+        System.out.println("in advice, arg = " + id + " (before proceed)");
+        proceed();
+        System.out.println("in advice (after proceed)");
+    }
+}
index e2fcbcca2e10410df82ce4fa30ba96244558b80c..77f2cb55e130986a77f2cccb8cad10f5d6fdf5f1 100644 (file)
@@ -23,6 +23,59 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
 
 public class Ajc163Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
 
+       public void testBrokenLVT_pr194314_1() {
+               runTest("broken lvt - 1");
+               JavaClass jc = Utils.getClassFrom(ajc.getSandboxDirectory().getAbsolutePath(), "Service");
+               Method[] ms = jc.getMethods();
+               Method m = null;
+               for (int i = 0; i < ms.length; i++) {
+                       if (ms[i].getName().equals("method_aroundBody1$advice")) {
+                               m = ms[i];
+                       }
+               }
+               if (m.getLocalVariableTable() == null) {
+                       fail("Local variable table should not be null");
+               }
+               System.out.println(m.getLocalVariableTable());
+               LocalVariable[] lvt = m.getLocalVariableTable().getLocalVariableTable();
+               assertEquals(8, lvt.length);
+       }
+
+       public void testBrokenLVT_pr194314_2() throws Exception {
+               runTest("broken lvt - 2");
+               JavaClass jc = Utils.getClassFrom(ajc.getSandboxDirectory().getAbsolutePath(), "Service");
+               Method[] ms = jc.getMethods();
+               Method m = null;
+               for (int i = 0; i < ms.length; i++) {
+                       if (ms[i].getName().equals("method_aroundBody1$advice")) {
+                               m = ms[i];
+                       }
+               }
+               if (m.getLocalVariableTable() == null) {
+                       fail("Local variable table should not be null");
+               }
+               System.out.println(m.getLocalVariableTable());
+               LocalVariable[] lvt = m.getLocalVariableTable().getLocalVariableTable();
+               assertEquals(8, lvt.length);
+               // assertEquals(2, m.getLocalVariableTable().getLocalVariableTable().length);
+
+               // Before I've started any work on this:
+               // LocalVariable(start_pc = 0, length = 68, index = 0:ServiceInterceptorCodeStyle this)
+               // LocalVariable(start_pc = 0, length = 68, index = 1:org.aspectj.runtime.internal.AroundClosure ajc_aroundClosure)
+               // LocalVariable(start_pc = 0, length = 68, index = 2:org.aspectj.lang.JoinPoint thisJoinPoint)
+               // LocalVariable(start_pc = 9, length = 59, index = 3:Object[] args)
+               // LocalVariable(start_pc = 21, length = 47, index = 4:long id)
+
+               // Method signature:
+               // private static final void method_aroundBody1$advice(Service, long, org.aspectj.lang.JoinPoint,
+               // ServiceInterceptorCodeStyle, org.aspectj.runtime.internal.AroundClosure, org.aspectj.lang.JoinPoint);
+               //
+               // Service, JoinPoint, ServiceInterceptorCodeStyle, AroundClosure, JoinPoint
+
+               // args should be in slot 7 and the long in position 8
+
+       }
+
        public void testDontAddMethodBodiesToInterface_pr163005() {
                runTest("do not add method bodies to an interface");
        }
index 39dba19eb533a8706cbf817f2111845cfc271b1d..c76014610d9043e6d30b2f166a041bc5402f4c6c 100644 (file)
@@ -3,6 +3,14 @@
 <suite>
 
 
+    <ajc-test dir="bugs163/pr194314" title="broken lvt - 1">
+      <compile files="Service.java IService.java Main.java ServiceInterceptor.java" options="-1.5"/>
+    </ajc-test>
+    
+    <ajc-test dir="bugs163/pr194314" title="broken lvt - 2">
+      <compile files="Service.java IService.java Main.java ServiceInterceptorCodeStyle.java" options="-1.5"/>
+    </ajc-test>
+
     <ajc-test dir="bugs163/pr163005" title="do not add method bodies to an interface">
       <compile files="Code.java" options="-1.4">
         <message kind="warning" text="The joinpoint 'method-call(java.lang.Class java.lang.Class.forName(java.lang.String))' cannot be advised"/>