]> source.dussan.org Git - aspectj.git/commitdiff
173978: test and fix: local var table for method-execution and around advice
authoraclement <aclement>
Thu, 30 Oct 2008 15:43:42 +0000 (15:43 +0000)
committeraclement <aclement>
Thu, 30 Oct 2008 15:43:42 +0000 (15:43 +0000)
tests/bugs163/pr173978/Test.java [new file with mode: 0644]
tests/bugs163/pr173978/TestAroundAspect.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc161/Ajc161Tests.java
tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java
tests/src/org/aspectj/systemtest/ajc163/ajc163.xml

diff --git a/tests/bugs163/pr173978/Test.java b/tests/bugs163/pr173978/Test.java
new file mode 100644 (file)
index 0000000..459d3cd
--- /dev/null
@@ -0,0 +1,7 @@
+public class Test{
+  public void sayHello(String message){
+    System.out.println(message);
+  }
+}
+
+
diff --git a/tests/bugs163/pr173978/TestAroundAspect.java b/tests/bugs163/pr173978/TestAroundAspect.java
new file mode 100644 (file)
index 0000000..9a884dd
--- /dev/null
@@ -0,0 +1,6 @@
+public aspect TestAroundAspect{
+  void around(): execution(void Test.sayHello(String)){
+    proceed();
+  }
+}
+
index ee702e5e1340ca12c5bb92e7f6bd2a84d27cfddc..dfb8ca594fe71b033284d63623945e9759565403 100644 (file)
@@ -16,8 +16,6 @@ import java.util.Set;
 
 import junit.framework.Test;
 
-import org.aspectj.apache.bcel.classfile.LocalVariable;
-import org.aspectj.apache.bcel.classfile.LocalVariableTable;
 import org.aspectj.asm.AsmManager;
 import org.aspectj.asm.IRelationshipMap;
 import org.aspectj.testing.XMLBasedAjcTestCase;
@@ -154,28 +152,6 @@ public class Ajc161Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
                }
        }
 
-       // public void testLVTableAround_pr173978() throws Exception {
-       // runTest("lv table for around");
-       // JavaClass jc = Utils.getClassFrom(ajc.getSandboxDirectory().getAbsolutePath(),"Test");
-       // Method[] ms = jc.getMethods();
-       // Method m = null;
-       // for (int i = 0; i < ms.length; i++) {
-       // if (ms[i].getName().equals("sayHello")) {
-       // m = ms[i];
-       // }
-       // }
-       // if (m.getLocalVariableTable()==null) fail("Local variable table should not be null");
-       // print(m.getLocalVariableTable());
-       // }
-
-       private void print(LocalVariableTable localVariableTable) {
-               LocalVariable[] lvs = localVariableTable.getLocalVariableTable();
-               for (int i = 0; i < lvs.length; i++) {
-                       LocalVariable localVariable = lvs[i];
-                       System.out.println(localVariable);
-               }
-       }
-
        public void testITDPrecedence_pr233838_1() {
                runTest("itd precedence - 1");
        }
index 7563a372b9d8d1592981585e4c0b981be2ea4aaa..e0dadda18a45cb310bcafa554195af1400a5ebd5 100644 (file)
@@ -14,10 +14,48 @@ import java.io.File;
 
 import junit.framework.Test;
 
+import org.aspectj.apache.bcel.classfile.JavaClass;
+import org.aspectj.apache.bcel.classfile.LocalVariable;
+import org.aspectj.apache.bcel.classfile.LocalVariableTable;
+import org.aspectj.apache.bcel.classfile.Method;
+import org.aspectj.testing.Utils;
 import org.aspectj.testing.XMLBasedAjcTestCase;
 
 public class Ajc163Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
 
+       public void testMissingLocalVariableTableEntriesOnAroundAdvice_pr173978() throws Exception {
+               runTest("missing local variable table on around advice");
+               JavaClass jc = Utils.getClassFrom(ajc.getSandboxDirectory().getAbsolutePath(), "Test");
+               Method[] ms = jc.getMethods();
+               Method m = null;
+               for (int i = 0; i < ms.length; i++) {
+                       if (ms[i].getName().equals("sayHello")) {
+                               m = ms[i];
+                       }
+               }
+               if (m.getLocalVariableTable() == null) {
+                       fail("Local variable table should not be null");
+               }
+               assertEquals(2, m.getLocalVariableTable().getLocalVariableTable().length);
+               // LocalVariableTable:
+               // Start Length Slot Name Signature
+               // 0 12 0 this LTest;
+               // 0 12 1 message Ljava/lang/String;
+               LocalVariable lv = m.getLocalVariableTable().getLocalVariable(0);
+               assertNotNull(lv);
+               assertEquals("this", lv.getName());
+               assertEquals(0, lv.getStartPC(), 0);
+               assertEquals(12, lv.getLength(), 12);
+               assertEquals("LTest;", lv.getSignature());
+               lv = m.getLocalVariableTable().getLocalVariable(1);
+               assertNotNull(lv);
+               assertEquals("message", lv.getName());
+               assertEquals(0, lv.getStartPC(), 0);
+               assertEquals(12, lv.getLength(), 12);
+               assertEquals("Ljava/lang/String;", lv.getSignature());
+               // print(m.getLocalVariableTable());
+       }
+
        public void testTerminateAfterCompilation_pr249710() {
                runTest("terminateAfterCompilation");
        }
@@ -50,4 +88,14 @@ public class Ajc163Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
                return new File("../tests/src/org/aspectj/systemtest/ajc163/ajc163.xml");
        }
 
+       // ---
+
+       private void print(LocalVariableTable localVariableTable) {
+               LocalVariable[] lvs = localVariableTable.getLocalVariableTable();
+               for (int i = 0; i < lvs.length; i++) {
+                       LocalVariable localVariable = lvs[i];
+                       System.out.println(localVariable);
+               }
+       }
+
 }
\ No newline at end of file
index 921444abec256fb1a96c9992c50d179673659758..9119c6f5ded86ec8a42bb423fb5db0372166fef1 100644 (file)
         <message kind="error" line="4" text="Syntax error"/>
       </compile>
     </ajc-test>
+    
+    <ajc-test dir="bugs163/pr173978" title="missing local variable table on around advice">
+      <compile files="Test.java TestAroundAspect.java" options="-1.5"/>
+    </ajc-test>
 
     <ajc-test dir="bugs163/pr249710" title="terminateAfterCompilation">
       <compile files="Foo.java" options="-1.5">