commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1695997 - in /commons/proper/bcel/trunk/src: main/java/org/apache/commons/bcel6/generic/MethodGen.java test/java/org/apache/commons/bcel6/PLSETestCase.java test/java/org/apache/commons/bcel6/data/PLSETestClass.java
Date Fri, 14 Aug 2015 22:22:48 GMT
Author: sebb
Date: Fri Aug 14 22:22:47 2015
New Revision: 1695997

URL: http://svn.apache.org/r1695997
Log:
BCEL-79 - Add test to show the problem, and re-fix it

Modified:
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/MethodGen.java
    commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/PLSETestCase.java
    commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/data/PLSETestClass.java

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/MethodGen.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/MethodGen.java?rev=1695997&r1=1695996&r2=1695997&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/MethodGen.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/MethodGen.java
Fri Aug 14 22:22:47 2015
@@ -35,7 +35,6 @@ import org.apache.commons.bcel6.classfil
 import org.apache.commons.bcel6.classfile.LineNumberTable;
 import org.apache.commons.bcel6.classfile.LocalVariable;
 import org.apache.commons.bcel6.classfile.LocalVariableTable;
-import org.apache.commons.bcel6.classfile.LocalVariableTypeTable;
 import org.apache.commons.bcel6.classfile.Method;
 import org.apache.commons.bcel6.classfile.ParameterAnnotationEntry;
 import org.apache.commons.bcel6.classfile.ParameterAnnotations;
@@ -228,22 +227,6 @@ public class MethodGen extends FieldGenO
                         removeLocalVariables();
                         for (LocalVariable l : lv) {
                             InstructionHandle start = il.findHandle(l.getStartPC());
-                            InstructionHandle end = il.findHandle(l.getStartPC() + l.getLength());
-                            // Repair malformed handles
-                            if (null == start) {
-                                start = il.getStart();
-                            }
-                            if (null == end) {
-                                end = il.getEnd();
-                            }
-                            addLocalVariable(l.getName(), Type.getType(l.getSignature()),
l
-                                    .getIndex(), start, end);
-                        }
-                    } else if (a instanceof LocalVariableTypeTable) {
-                        LocalVariable[] lv = ((LocalVariableTypeTable) a).getLocalVariableTypeTable();
-                        removeLocalVariables();
-                        for (LocalVariable l : lv) {
-                            InstructionHandle start = il.findHandle(l.getStartPC());
                             InstructionHandle end = il.findHandle(l.getStartPC() + l.getLength());
                             // Repair malformed handles
                             if (null == start) {

Modified: commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/PLSETestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/PLSETestCase.java?rev=1695997&r1=1695996&r2=1695997&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/PLSETestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/PLSETestCase.java Fri
Aug 14 22:22:47 2015
@@ -19,6 +19,7 @@
 package org.apache.commons.bcel6;
 
 import org.apache.commons.bcel6.classfile.JavaClass;
+import org.apache.commons.bcel6.classfile.LocalVariableTable;
 import org.apache.commons.bcel6.classfile.Method;
 import org.apache.commons.bcel6.generic.ClassGen;
 import org.apache.commons.bcel6.generic.ConstantPoolGen;
@@ -43,4 +44,22 @@ public class PLSETestCase extends Abstra
         // currently, this will cause null pointer exception
         mg.getLocalVariableTable(pool);
     }
+
+    /**
+     * BCEL-79: 
+     */
+    public void testB79() throws ClassNotFoundException
+    {
+        JavaClass clazz = getTestClass("org.apache.commons.bcel6.data.PLSETestClass");
+        ClassGen gen = new ClassGen(clazz);
+        ConstantPoolGen pool = gen.getConstantPool();
+        Method m = gen.getMethodAt(2);
+        LocalVariableTable lvt = m.getLocalVariableTable();
+        //System.out.println(lvt);
+        //System.out.println(lvt.getTableLength());
+        MethodGen mg = new MethodGen(m, gen.getClassName(), pool);
+        LocalVariableTable new_lvt = mg.getLocalVariableTable(mg.getConstantPool());
+        //System.out.println(new_lvt);
+        assertEquals("number of locals", lvt.getTableLength(), new_lvt.getTableLength());
+    }
 }

Modified: commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/data/PLSETestClass.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/data/PLSETestClass.java?rev=1695997&r1=1695996&r2=1695997&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/data/PLSETestClass.java
(original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/data/PLSETestClass.java
Fri Aug 14 22:22:47 2015
@@ -18,11 +18,19 @@
 
 package org.apache.commons.bcel6.data;
 
+import java.util.ArrayList;
+
 public class PLSETestClass
 {
     public void meth1(int arg1)
     {
         @SuppressWarnings("unused")
         int local1 = arg1;
+    }
+
+    public void meth2(int arg1, ArrayList<String> arg2, int arg3)
+    {
+        @SuppressWarnings("unused")
+        int local1 = arg1;
     }
 }



Mime
View raw message