From: aclement Date: Thu, 30 Oct 2008 15:43:42 +0000 (+0000) Subject: 173978: test and fix: local var table for method-execution and around advice X-Git-Tag: V1_6_3rc1~122 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=19e1e92ad7a75f9f00c4a31ce7db98527f2c0c62;p=aspectj.git 173978: test and fix: local var table for method-execution and around advice --- diff --git a/tests/bugs163/pr173978/Test.java b/tests/bugs163/pr173978/Test.java new file mode 100644 index 000000000..459d3cd20 --- /dev/null +++ b/tests/bugs163/pr173978/Test.java @@ -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 index 000000000..9a884dd63 --- /dev/null +++ b/tests/bugs163/pr173978/TestAroundAspect.java @@ -0,0 +1,6 @@ +public aspect TestAroundAspect{ + void around(): execution(void Test.sayHello(String)){ + proceed(); + } +} + diff --git a/tests/src/org/aspectj/systemtest/ajc161/Ajc161Tests.java b/tests/src/org/aspectj/systemtest/ajc161/Ajc161Tests.java index ee702e5e1..dfb8ca594 100644 --- a/tests/src/org/aspectj/systemtest/ajc161/Ajc161Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc161/Ajc161Tests.java @@ -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"); } diff --git a/tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java b/tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java index 7563a372b..e0dadda18 100644 --- a/tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java @@ -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 diff --git a/tests/src/org/aspectj/systemtest/ajc163/ajc163.xml b/tests/src/org/aspectj/systemtest/ajc163/ajc163.xml index 921444abe..9119c6f5d 100644 --- a/tests/src/org/aspectj/systemtest/ajc163/ajc163.xml +++ b/tests/src/org/aspectj/systemtest/ajc163/ajc163.xml @@ -18,6 +18,10 @@ + + + +