aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorehilsdal <ehilsdal>2004-01-29 13:46:27 +0000
committerehilsdal <ehilsdal>2004-01-29 13:46:27 +0000
commitf5f74fd0bf1770273998aa3010c524a29dccd520 (patch)
treec9c5404e78c4ca897c7401ed984dc07710b582a5
parentbece4680e604416148871e60cef77f0cd0808aba (diff)
downloadaspectj-f5f74fd0bf1770273998aa3010c524a29dccd520.tar.gz
aspectj-f5f74fd0bf1770273998aa3010c524a29dccd520.zip
Fix for Bugzilla Bug 41125:
LocalVariableTable sometimes gets BCEL-supplied parameter names
-rw-r--r--bcel-builder/.classpath1
-rw-r--r--bcel-builder/build.xml21
-rw-r--r--bcel-builder/patch.txt284
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java39
4 files changed, 307 insertions, 38 deletions
diff --git a/bcel-builder/.classpath b/bcel-builder/.classpath
index 795a5a614..7c0df08e1 100644
--- a/bcel-builder/.classpath
+++ b/bcel-builder/.classpath
@@ -2,5 +2,6 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="/lib/regexp/jakarta-regexp-1.2.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/bcel-builder/build.xml b/bcel-builder/build.xml
index a12e7ef7c..0310d4c3f 100644
--- a/bcel-builder/build.xml
+++ b/bcel-builder/build.xml
@@ -4,21 +4,36 @@
<target name="jar">
<copy file="../lib/regexp/jakarta-regexp-1.2.jar"
- tofile="bcel/lib/regexp-1.2.jar" />
+ tofile="bcel/lib/Regex.jar" />
<ant dir="bcel" target="jar" />
<copy file="bcel/bin/bcel.jar" toDir="." />
</target>
+ <target name="update">
+ <copy file="bcel.jar" todir="../lib/bcel" />
+ </target>
+
<target name="pack">
+ <move toDir="bcel/src/java">
+ <fileset dir="src" />
+ </move>
</target>
- <target name="unpack" depends="extract,patch" />
+ <target name="unpack" depends="extract,patch,srcclean">
+ <move toDir="src">
+ <fileset dir="bcel/src/java" />
+ </move>
+ </target>
<target name="extract">
<unzip src="bcel-5.1-src.zip" dest="." />
</target>
- <target name="clean">
+ <target name="srcclean">
+ <delete dir="src/org" />
+ </target>
+
+ <target name="clean" depends="srcclean">
<delete dir="bcel-5.1" />
<delete dir="bcel" />
</target>
diff --git a/bcel-builder/patch.txt b/bcel-builder/patch.txt
index d1583af47..f1d7b3417 100644
--- a/bcel-builder/patch.txt
+++ b/bcel-builder/patch.txt
@@ -1,6 +1,6 @@
diff -N -a -u -r -b bcel-5.1/build.xml bcel/build.xml
--- bcel-5.1/build.xml 2003-04-25 09:06:14.000000000 -0700
-+++ bcel/build.xml 2004-01-27 11:15:53.460625000 -0800
++++ bcel/build.xml 2004-01-29 04:37:15.593750000 -0800
@@ -65,7 +65,7 @@
<target name="build" depends="compile"/>
@@ -12,8 +12,288 @@ diff -N -a -u -r -b bcel-5.1/build.xml bcel/build.xml
manifest="${basedir}/manifest.txt"
diff -N -a -u -r -b bcel-5.1/manifest.txt bcel/manifest.txt
--- bcel-5.1/manifest.txt 1969-12-31 16:00:00.000000000 -0800
-+++ bcel/manifest.txt 2004-01-27 11:14:51.835625000 -0800
++++ bcel/manifest.txt 2004-01-29 04:37:15.609375000 -0800
@@ -0,0 +1,3 @@
+Created-By: Jakarta BCEL 5.1
+Manifest-Version: 1.0
+Main-Class: listclass
+diff -N -a -u -r -b bcel-5.1/src/java/org/apache/bcel/generic/Instruction.java bcel/src/java/org/apache/bcel/generic/Instruction.java
+--- bcel-5.1/src/java/org/apache/bcel/generic/Instruction.java 2003-04-25 09:06:16.000000000 -0700
++++ bcel/src/java/org/apache/bcel/generic/Instruction.java 2004-01-29 04:37:15.640625000 -0800
+@@ -190,26 +190,223 @@
+ Class clazz;
+
+ try {
+- clazz = Class.forName(className(opcode));
+- } catch (ClassNotFoundException cnfe){
+- // If a class by that name does not exist, the opcode is illegal.
+- // Note that IMPDEP1, IMPDEP2, BREAKPOINT are also illegal in a sense.
+- throw new ClassGenException("Illegal opcode detected.");
++ switch(opcode) {
++ case Constants.NOP: obj = new NOP(); break;
++ case Constants.ACONST_NULL: obj = new ACONST_NULL(); break;
++ case Constants.ICONST_M1:
++ case Constants.ICONST_0:
++ case Constants.ICONST_1:
++ case Constants.ICONST_2:
++ case Constants.ICONST_3:
++ case Constants.ICONST_4:
++ case Constants.ICONST_5: obj = new ICONST(); break;
++ case Constants.LCONST_0:
++ case Constants.LCONST_1: obj = new LCONST(); break;
++ case Constants.FCONST_0:
++ case Constants.FCONST_1:
++ case Constants.FCONST_2: obj = new FCONST(); break;
++ case Constants.DCONST_0:
++ case Constants.DCONST_1: obj = new DCONST(); break;
++ case Constants.BIPUSH : obj = new BIPUSH(); break;
++ case Constants.SIPUSH : obj = new SIPUSH(); break;
++ case Constants.LDC : obj = new LDC(); break;
++ case Constants.LDC_W: obj = new LDC_W(); break;
++ case Constants.LDC2_W: obj = new LDC2_W(); break;
++ case Constants.ILOAD : obj = new ILOAD(); break;
++ case Constants.LLOAD : obj = new LLOAD(); break;
++ case Constants.FLOAD : obj = new FLOAD(); break;
++ case Constants.DLOAD : obj = new DLOAD(); break;
++ case Constants.ALOAD : obj = new ALOAD(); break;
++ case Constants.ILOAD_0:
++ case Constants.ILOAD_1:
++ case Constants.ILOAD_2:
++ case Constants.ILOAD_3: obj = new ILOAD(); break;
++ case Constants.LLOAD_0:
++ case Constants.LLOAD_1:
++ case Constants.LLOAD_2:
++ case Constants.LLOAD_3: obj = new LLOAD(); break;
++ case Constants.FLOAD_0:
++ case Constants.FLOAD_1:
++ case Constants.FLOAD_2:
++ case Constants.FLOAD_3: obj = new FLOAD(); break;
++ case Constants.DLOAD_0:
++ case Constants.DLOAD_1:
++ case Constants.DLOAD_2:
++ case Constants.DLOAD_3: obj = new DLOAD(); break;
++ case Constants.ALOAD_0:
++ case Constants.ALOAD_1:
++ case Constants.ALOAD_2:
++ case Constants.ALOAD_3: obj = new ALOAD(); break;
++ case Constants.IALOAD : obj = new IALOAD(); break;
++ case Constants.LALOAD : obj = new LALOAD(); break;
++ case Constants.FALOAD : obj = new FALOAD(); break;
++ case Constants.DALOAD : obj = new DALOAD(); break;
++ case Constants.AALOAD : obj = new AALOAD(); break;
++ case Constants.BALOAD : obj = new BALOAD(); break;
++ case Constants.CALOAD : obj = new CALOAD(); break;
++ case Constants.SALOAD : obj = new SALOAD(); break;
++ case Constants.ISTORE : obj = new ISTORE(); break;
++ case Constants.LSTORE : obj = new LSTORE(); break;
++ case Constants.FSTORE : obj = new FSTORE(); break;
++ case Constants.DSTORE : obj = new DSTORE(); break;
++ case Constants.ASTORE : obj = new ASTORE(); break;
++ case Constants.ISTORE_0:
++ case Constants.ISTORE_1:
++ case Constants.ISTORE_2:
++ case Constants.ISTORE_3: obj = new ISTORE(); break;
++ case Constants.LSTORE_0:
++ case Constants.LSTORE_1:
++ case Constants.LSTORE_2:
++ case Constants.LSTORE_3: obj = new LSTORE(); break;
++ case Constants.FSTORE_0:
++ case Constants.FSTORE_1:
++ case Constants.FSTORE_2:
++ case Constants.FSTORE_3: obj = new FSTORE(); break;
++ case Constants.DSTORE_0:
++ case Constants.DSTORE_1:
++ case Constants.DSTORE_2:
++ case Constants.DSTORE_3: obj = new DSTORE(); break;
++ case Constants.ASTORE_0:
++ case Constants.ASTORE_1:
++ case Constants.ASTORE_2:
++ case Constants.ASTORE_3: obj = new ASTORE(); break;
++ case Constants.IASTORE : obj = new IASTORE(); break;
++ case Constants.LASTORE : obj = new LASTORE(); break;
++ case Constants.FASTORE : obj = new FASTORE(); break;
++ case Constants.DASTORE : obj = new DASTORE(); break;
++ case Constants.AASTORE : obj = new AASTORE(); break;
++ case Constants.BASTORE : obj = new BASTORE(); break;
++ case Constants.CASTORE : obj = new CASTORE(); break;
++ case Constants.SASTORE : obj = new SASTORE(); break;
++ case Constants.POP : obj = new POP(); break;
++ case Constants.POP2 : obj = new POP2(); break;
++ case Constants.DUP : obj = new DUP(); break;
++ case Constants.DUP_X1: obj = new DUP_X1(); break;
++ case Constants.DUP_X2: obj = new DUP_X2(); break;
++ case Constants.DUP2 : obj = new DUP2(); break;
++ case Constants.DUP2_X1: obj = new DUP2_X1(); break;
++ case Constants.DUP2_X2: obj = new DUP2_X2(); break;
++ case Constants.SWAP : obj = new SWAP(); break;
++ case Constants.IADD : obj = new IADD(); break;
++ case Constants.LADD : obj = new LADD(); break;
++ case Constants.FADD : obj = new FADD(); break;
++ case Constants.DADD : obj = new DADD(); break;
++ case Constants.ISUB : obj = new ISUB(); break;
++ case Constants.LSUB : obj = new LSUB(); break;
++ case Constants.FSUB : obj = new FSUB(); break;
++ case Constants.DSUB : obj = new DSUB(); break;
++ case Constants.IMUL : obj = new IMUL(); break;
++ case Constants.LMUL : obj = new LMUL(); break;
++ case Constants.FMUL : obj = new FMUL(); break;
++ case Constants.DMUL : obj = new DMUL(); break;
++ case Constants.IDIV : obj = new IDIV(); break;
++ case Constants.LDIV : obj = new LDIV(); break;
++ case Constants.FDIV : obj = new FDIV(); break;
++ case Constants.DDIV : obj = new DDIV(); break;
++ case Constants.IREM : obj = new IREM(); break;
++ case Constants.LREM : obj = new LREM(); break;
++ case Constants.FREM : obj = new FREM(); break;
++ case Constants.DREM : obj = new DREM(); break;
++ case Constants.INEG : obj = new INEG(); break;
++ case Constants.LNEG : obj = new LNEG(); break;
++ case Constants.FNEG : obj = new FNEG(); break;
++ case Constants.DNEG : obj = new DNEG(); break;
++ case Constants.ISHL : obj = new ISHL(); break;
++ case Constants.LSHL : obj = new LSHL(); break;
++ case Constants.ISHR : obj = new ISHR(); break;
++ case Constants.LSHR : obj = new LSHR(); break;
++ case Constants.IUSHR : obj = new IUSHR(); break;
++ case Constants.LUSHR : obj = new LUSHR(); break;
++ case Constants.IAND : obj = new IAND(); break;
++ case Constants.LAND : obj = new LAND(); break;
++ case Constants.IOR : obj = new IOR(); break;
++ case Constants.LOR : obj = new LOR(); break;
++ case Constants.IXOR : obj = new IXOR(); break;
++ case Constants.LXOR : obj = new LXOR(); break;
++ case Constants.IINC : obj = new IINC(); break;
++ case Constants.I2L : obj = new I2L(); break;
++ case Constants.I2F : obj = new I2F(); break;
++ case Constants.I2D : obj = new I2D(); break;
++ case Constants.L2I : obj = new L2I(); break;
++ case Constants.L2F : obj = new L2F(); break;
++ case Constants.L2D : obj = new L2D(); break;
++ case Constants.F2I : obj = new F2I(); break;
++ case Constants.F2L : obj = new F2L(); break;
++ case Constants.F2D : obj = new F2D(); break;
++ case Constants.D2I : obj = new D2I(); break;
++ case Constants.D2L : obj = new D2L(); break;
++ case Constants.D2F : obj = new D2F(); break;
++ case Constants.I2B : obj = new I2B(); break;
++ case Constants.I2C : obj = new I2C(); break;
++ case Constants.I2S : obj = new I2S(); break;
++ case Constants.LCMP : obj = new LCMP(); break;
++ case Constants.FCMPL : obj = new FCMPL(); break;
++ case Constants.FCMPG : obj = new FCMPG(); break;
++ case Constants.DCMPL : obj = new DCMPL(); break;
++ case Constants.DCMPG : obj = new DCMPG(); break;
++ case Constants.IFEQ : obj = new IFEQ(); break;
++ case Constants.IFNE : obj = new IFNE(); break;
++ case Constants.IFLT : obj = new IFLT(); break;
++ case Constants.IFGE : obj = new IFGE(); break;
++ case Constants.IFGT : obj = new IFGT(); break;
++ case Constants.IFLE : obj = new IFLE(); break;
++ case Constants.IF_ICMPEQ: obj = new IF_ICMPEQ(); break;
++ case Constants.IF_ICMPNE: obj = new IF_ICMPNE(); break;
++ case Constants.IF_ICMPLT: obj = new IF_ICMPLT(); break;
++ case Constants.IF_ICMPGE: obj = new IF_ICMPGE(); break;
++ case Constants.IF_ICMPGT: obj = new IF_ICMPGT(); break;
++ case Constants.IF_ICMPLE: obj = new IF_ICMPLE(); break;
++ case Constants.IF_ACMPEQ: obj = new IF_ACMPEQ(); break;
++ case Constants.IF_ACMPNE : obj = new IF_ACMPNE(); break;
++ case Constants.GOTO : obj = new GOTO(); break;
++ case Constants.JSR : obj = new JSR(); break;
++ case Constants.RET : obj = new RET(); break;
++ case Constants.TABLESWITCH : obj = new TABLESWITCH(); break;
++ case Constants.LOOKUPSWITCH : obj = new LOOKUPSWITCH(); break;
++ case Constants.IRETURN : obj = new IRETURN(); break;
++ case Constants.LRETURN : obj = new LRETURN(); break;
++ case Constants.FRETURN : obj = new FRETURN(); break;
++ case Constants.DRETURN : obj = new DRETURN(); break;
++ case Constants.ARETURN : obj = new ARETURN(); break;
++ case Constants.RETURN : obj = new RETURN(); break;
++ case Constants.GETSTATIC : obj = new GETSTATIC(); break;
++ case Constants.PUTSTATIC : obj = new PUTSTATIC(); break;
++ case Constants.GETFIELD : obj = new GETFIELD(); break;
++ case Constants.PUTFIELD : obj = new PUTFIELD(); break;
++ case Constants.INVOKEVIRTUAL : obj = new INVOKEVIRTUAL(); break;
++ case Constants.INVOKESPECIAL : obj = new INVOKESPECIAL(); break;
++ case Constants.INVOKESTATIC : obj = new INVOKESTATIC(); break;
++ case Constants.INVOKEINTERFACE : obj = new INVOKEINTERFACE(); break;
++ case Constants.NEW : obj = new NEW(); break;
++ case Constants.NEWARRAY : obj = new NEWARRAY(); break;
++ case Constants.ANEWARRAY : obj = new ANEWARRAY(); break;
++ case Constants.ARRAYLENGTH : obj = new ARRAYLENGTH(); break;
++ case Constants.ATHROW : obj = new ATHROW(); break;
++ case Constants.CHECKCAST : obj = new CHECKCAST(); break;
++ case Constants.INSTANCEOF : obj = new INSTANCEOF(); break;
++ case Constants.MONITORENTER : obj = new MONITORENTER(); break;
++ case Constants.MONITOREXIT : obj = new MONITOREXIT(); break;
++ case Constants.MULTIANEWARRAY : obj = new MULTIANEWARRAY(); break;
++ case Constants.IFNULL : obj = new IFNULL(); break;
++ case Constants.IFNONNULL : obj = new IFNONNULL(); break;
++ case Constants.GOTO_W : obj = new GOTO_W(); break;
++ case Constants.JSR_W : obj = new JSR_W(); break;
++ default:
++ throw new ClassGenException("Illegal opcode detected");
++ }
++ } catch (ClassGenException e) {
++ throw e;
++ } catch (Exception e) {
++ throw new ClassGenException(e.toString());
+ }
+-
+- try {
+- obj = (Instruction)clazz.newInstance();
+-
+ if(wide && !((obj instanceof LocalVariableInstruction) ||
+ (obj instanceof IINC) ||
+ (obj instanceof RET)))
+- throw new Exception("Illegal opcode after wide: " + opcode);
++ throw new ClassGenException("Illegal opcode after wide: " + opcode);
+
+ obj.setOpcode(opcode);
+ obj.initFromFile(bytes, wide); // Do further initializations, if any
+ // Byte code offset set in InstructionList
+- } catch(Exception e) { throw new ClassGenException(e.toString()); }
+-
+ return obj;
+ }
+
+diff -N -a -u -r -b bcel-5.1/src/java/org/apache/bcel/generic/MethodGen.java bcel/src/java/org/apache/bcel/generic/MethodGen.java
+--- bcel-5.1/src/java/org/apache/bcel/generic/MethodGen.java 2003-04-25 09:06:16.000000000 -0700
++++ bcel/src/java/org/apache/bcel/generic/MethodGen.java 2004-01-29 04:39:47.265625000 -0800
+@@ -133,9 +133,9 @@
+
+ /* Add local variables, namely the implicit `this' and the arguments
+ */
+- if(!isStatic() && (class_name != null)) { // Instance method -> `this' is local var 0
+- addLocalVariable("this", new ObjectType(class_name), start, end);
+- }
++// if(!isStatic() && (class_name != null)) { // Instance method -> `this' is local var 0
++// addLocalVariable("this", new ObjectType(class_name), start, end);
++// }
+ }
+
+ if(arg_types != null) {
+@@ -152,17 +152,17 @@
+ throw new ClassGenException("Mismatch in argument array lengths: " +
+ size + " vs. " + arg_names.length);
+ } else { // Give them dummy names
+- arg_names = new String[size];
+-
+- for(int i=0; i < size; i++)
+- arg_names[i] = "arg" + i;
+-
+- setArgumentNames(arg_names);
++// arg_names = new String[size];
++//
++// for(int i=0; i < size; i++)
++// arg_names[i] = "arg" + i;
++//
++// setArgumentNames(arg_names);
+ }
+
+ if(!abstract_) {
+ for(int i=0; i < size; i++) {
+- addLocalVariable(arg_names[i], arg_types[i], start, end);
++// addLocalVariable(arg_names[i], arg_types[i], start, end);
+ }
+ }
+ }
diff --git a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
index 8cb337b35..d3c8dc0b0 100644
--- a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
+++ b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
@@ -17,8 +17,6 @@ import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -54,9 +52,7 @@ import org.aspectj.bridge.IMessage;
import org.aspectj.weaver.AjAttribute;
import org.aspectj.weaver.BCException;
import org.aspectj.weaver.ISourceContext;
-import org.aspectj.weaver.Member;
import org.aspectj.weaver.ResolvedTypeX;
-import org.aspectj.weaver.TypeX;
/**
@@ -915,38 +911,15 @@ public final class LazyMethodGen {
}
// now add local variables
gen.removeLocalVariables();
-
- // BCEL sometimes creates extra local variables with the same name. We now
- // remove them and add back to the gen.
+
+ // this next iteration _might_ be overkill, but we had problems with
+ // bcel before with duplicate local variables. Now that we're patching
+ // bcel we should be able to do without it if we're paranoid enough
+ // through the rest of the compiler.
Map duplicatedLocalMap = new HashMap();
- // Reverse sort these keys
- List keys = new ArrayList();
+ List keys = new ArrayList();
keys.addAll(localVariableStarts.keySet());
-// System.err.println("Keys for local variable tags");
-// for (int i = 0;i <keys.size();i++) {
-// System.err.println("Before sort: #"+i+"="+keys.get(i));
-// }
- Collections.sort(keys, new Comparator() {
- public int compare(Object a, Object b) {
- LocalVariableTag taga = (LocalVariableTag) a;
- LocalVariableTag tagb = (LocalVariableTag) b;
- if (taga.getName().startsWith("arg")) {
- if (tagb.getName().startsWith("arg")) {
- return -taga.getName().compareTo(tagb.getName());
- } else {
- return 1; // Whatever tagb is, it must come out before 'arg'
- }
- } else if (tagb.getName().startsWith("arg")) {
- return -1; // Whatever taga is, it must come out before 'arg'
- } else {
- return -taga.getName().compareTo(tagb.getName());
- }
- }
- });
-// for (int i = 0;i <keys.size();i++) {
-// System.err.println("After sort: #"+i+"="+keys.get(i));
-// }
for (Iterator iter = keys.iterator(); iter.hasNext(); ) {
LocalVariableTag tag = (LocalVariableTag) iter.next();
// have we already added one with the same slot number and start location?