You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2009/12/06 00:22:52 UTC
svn commit: r887610 [4/6] - in
/tomcat/trunk/java/org/apache/tomcat/util/bcel: ./ classfile/ generic/ util/
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/GETFIELD.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/GETFIELD.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/GETFIELD.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/GETFIELD.java Sat Dec 5 23:22:46 2009
@@ -16,9 +16,6 @@
*/
package org.apache.tomcat.util.bcel.generic;
-import org.apache.tomcat.util.bcel.Constants;
-import org.apache.tomcat.util.bcel.ExceptionConstants;
-
/**
* GETFIELD - Fetch field from object
* <PRE>Stack: ..., objectref -> ..., value</PRE>
@@ -39,9 +36,7 @@
}
- public GETFIELD(int index) {
- super(Constants.GETFIELD, index);
- }
+
public int produceStack( ConstantPoolGen cpg ) {
@@ -49,12 +44,5 @@
}
- public Class[] getExceptions() {
- Class[] cs = new Class[2 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length];
- System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0, cs, 0,
- ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length);
- cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length + 1] = ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR;
- cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] = ExceptionConstants.NULL_POINTER_EXCEPTION;
- return cs;
- }
+
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/GETSTATIC.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/GETSTATIC.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/GETSTATIC.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/GETSTATIC.java Sat Dec 5 23:22:46 2009
@@ -16,9 +16,6 @@
*/
package org.apache.tomcat.util.bcel.generic;
-import org.apache.tomcat.util.bcel.Constants;
-import org.apache.tomcat.util.bcel.ExceptionConstants;
-
/**
* GETSTATIC - Fetch static field from class
* <PRE>Stack: ..., -> ..., value</PRE>
@@ -38,9 +35,7 @@
}
- public GETSTATIC(int index) {
- super(Constants.GETSTATIC, index);
- }
+
public int produceStack( ConstantPoolGen cpg ) {
@@ -48,11 +43,5 @@
}
- public Class[] getExceptions() {
- Class[] cs = new Class[1 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length];
- System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0, cs, 0,
- ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length);
- cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] = ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR;
- return cs;
- }
+
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/GOTO.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/GOTO.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/GOTO.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/GOTO.java Sat Dec 5 23:22:46 2009
@@ -35,9 +35,7 @@
}
- public GOTO(InstructionHandle target) {
- super(org.apache.tomcat.util.bcel.Constants.GOTO, target);
- }
+
/**
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/GOTO_W.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/GOTO_W.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/GOTO_W.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/GOTO_W.java Sat Dec 5 23:22:46 2009
@@ -36,10 +36,7 @@
}
- public GOTO_W(InstructionHandle target) {
- super(org.apache.tomcat.util.bcel.Constants.GOTO_W, target);
- length = 5;
- }
+
/**
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/GotoInstruction.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/GotoInstruction.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/GotoInstruction.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/GotoInstruction.java Sat Dec 5 23:22:46 2009
@@ -24,9 +24,7 @@
*/
public abstract class GotoInstruction extends BranchInstruction implements UnconditionalBranch {
- GotoInstruction(short opcode, InstructionHandle target) {
- super(opcode, target);
- }
+
/**
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/IINC.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/IINC.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/IINC.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/IINC.java Sat Dec 5 23:22:46 2009
@@ -40,17 +40,7 @@
}
- /**
- * @param n index of local variable
- * @param c increment factor
- */
- public IINC(int n, int c) {
- super(); // Default behaviour of LocalVariableInstruction causes error
- this.opcode = org.apache.tomcat.util.bcel.Constants.IINC;
- this.length = (short) 3;
- setIndex(n); // May set wide as side effect
- setIncrement(c);
- }
+
/**
@@ -119,21 +109,10 @@
}
- /**
- * @return increment factor
- */
- public final int getIncrement() {
- return c;
- }
+
- /**
- * Set increment factor.
- */
- public final void setIncrement( int c ) {
- this.c = c;
- setWide();
- }
+
/** @return int type
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/INSTANCEOF.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/INSTANCEOF.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/INSTANCEOF.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/INSTANCEOF.java Sat Dec 5 23:22:46 2009
@@ -34,21 +34,11 @@
}
- public INSTANCEOF(int index) {
- super(org.apache.tomcat.util.bcel.Constants.INSTANCEOF, index);
- }
+
- public Class[] getExceptions() {
- return org.apache.tomcat.util.bcel.ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION;
- }
+
- public ObjectType getLoadClassType( ConstantPoolGen cpg ) {
- Type t = getType(cpg);
- if (t instanceof ArrayType) {
- t = ((ArrayType) t).getBasicType();
- }
- return (t instanceof ObjectType) ? (ObjectType) t : null;
- }
+
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/INVOKEINTERFACE.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/INVOKEINTERFACE.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/INVOKEINTERFACE.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/INVOKEINTERFACE.java Sat Dec 5 23:22:46 2009
@@ -18,8 +18,6 @@
import java.io.DataOutputStream;
import java.io.IOException;
-import org.apache.tomcat.util.bcel.Constants;
-import org.apache.tomcat.util.bcel.ExceptionConstants;
import org.apache.tomcat.util.bcel.classfile.ConstantPool;
import org.apache.tomcat.util.bcel.util.ByteSequence;
@@ -43,14 +41,7 @@
}
- public INVOKEINTERFACE(int index, int nargs) {
- super(Constants.INVOKEINTERFACE, index);
- length = 5;
- if (nargs < 1) {
- throw new ClassGenException("Number of arguments must be > 0 " + nargs);
- }
- this.nargs = nargs;
- }
+
/**
@@ -65,13 +56,7 @@
}
- /**
- * The <B>count</B> argument according to the Java Language Specification,
- * Second Edition.
- */
- public int getCount() {
- return nargs;
- }
+
/**
@@ -98,14 +83,5 @@
}
- public Class[] getExceptions() {
- Class[] cs = new Class[4 + ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION.length];
- System.arraycopy(ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION, 0, cs, 0,
- ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION.length);
- cs[ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION.length + 3] = ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR;
- cs[ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION.length + 2] = ExceptionConstants.ILLEGAL_ACCESS_ERROR;
- cs[ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION.length + 1] = ExceptionConstants.ABSTRACT_METHOD_ERROR;
- cs[ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION.length] = ExceptionConstants.UNSATISFIED_LINK_ERROR;
- return cs;
- }
+
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/INVOKESPECIAL.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/INVOKESPECIAL.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/INVOKESPECIAL.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/INVOKESPECIAL.java Sat Dec 5 23:22:46 2009
@@ -16,9 +16,6 @@
*/
package org.apache.tomcat.util.bcel.generic;
-import org.apache.tomcat.util.bcel.Constants;
-import org.apache.tomcat.util.bcel.ExceptionConstants;
-
/**
* INVOKESPECIAL - Invoke instance method; special handling for superclass, private
* and instance initialization method invocations
@@ -38,19 +35,8 @@
}
- public INVOKESPECIAL(int index) {
- super(Constants.INVOKESPECIAL, index);
- }
+
- public Class[] getExceptions() {
- Class[] cs = new Class[4 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length];
- System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0, cs, 0,
- ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length);
- cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length + 3] = ExceptionConstants.UNSATISFIED_LINK_ERROR;
- cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length + 2] = ExceptionConstants.ABSTRACT_METHOD_ERROR;
- cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length + 1] = ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR;
- cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] = ExceptionConstants.NULL_POINTER_EXCEPTION;
- return cs;
- }
+
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/INVOKESTATIC.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/INVOKESTATIC.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/INVOKESTATIC.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/INVOKESTATIC.java Sat Dec 5 23:22:46 2009
@@ -16,9 +16,6 @@
*/
package org.apache.tomcat.util.bcel.generic;
-import org.apache.tomcat.util.bcel.Constants;
-import org.apache.tomcat.util.bcel.ExceptionConstants;
-
/**
* INVOKESTATIC - Invoke a class (static) method
*
@@ -37,17 +34,8 @@
}
- public INVOKESTATIC(int index) {
- super(Constants.INVOKESTATIC, index);
- }
+
- public Class[] getExceptions() {
- Class[] cs = new Class[2 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length];
- System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0, cs, 0,
- ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length);
- cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] = ExceptionConstants.UNSATISFIED_LINK_ERROR;
- cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length + 1] = ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR;
- return cs;
- }
+
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/INVOKEVIRTUAL.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/INVOKEVIRTUAL.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/INVOKEVIRTUAL.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/INVOKEVIRTUAL.java Sat Dec 5 23:22:46 2009
@@ -16,9 +16,6 @@
*/
package org.apache.tomcat.util.bcel.generic;
-import org.apache.tomcat.util.bcel.Constants;
-import org.apache.tomcat.util.bcel.ExceptionConstants;
-
/**
* INVOKEVIRTUAL - Invoke instance method; dispatch based on class
*
@@ -37,19 +34,8 @@
}
- public INVOKEVIRTUAL(int index) {
- super(Constants.INVOKEVIRTUAL, index);
- }
+
- public Class[] getExceptions() {
- Class[] cs = new Class[4 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length];
- System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0, cs, 0,
- ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length);
- cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length + 3] = ExceptionConstants.UNSATISFIED_LINK_ERROR;
- cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length + 2] = ExceptionConstants.ABSTRACT_METHOD_ERROR;
- cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length + 1] = ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR;
- cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] = ExceptionConstants.NULL_POINTER_EXCEPTION;
- return cs;
- }
+
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/Instruction.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/Instruction.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/Instruction.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/Instruction.java Sat Dec 5 23:22:46 2009
@@ -19,7 +19,6 @@
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.Serializable;
-import java.util.Locale;
import org.apache.tomcat.util.bcel.Constants;
import org.apache.tomcat.util.bcel.classfile.ConstantPool;
import org.apache.tomcat.util.bcel.util.ByteSequence;
@@ -101,28 +100,7 @@
}
- /**
- * Use with caution, since `BranchInstruction's have a `target' reference which
- * is not copied correctly (only basic types are). This also applies for
- * `Select' instructions with their multiple branch targets.
- *
- * @see BranchInstruction
- * @return (shallow) copy of an instruction
- */
- public Instruction copy() {
- Instruction i = null;
- // "Constant" instruction, no need to duplicate
- if (InstructionConstants.INSTRUCTIONS[this.getOpcode()] != null) {
- i = this;
- } else {
- try {
- i = (Instruction) clone();
- } catch (CloneNotSupportedException e) {
- System.err.println(e);
- }
- }
- return i;
- }
+
/**
@@ -511,21 +489,10 @@
}
- /** Get Comparator object used in the equals() method to determine
- * equality of instructions.
- *
- * @return currently used comparator for equals()
- */
- public static InstructionComparator getComparator() {
- return cmp;
- }
+
- /** Set comparator to be used for equals().
- */
- public static void setComparator( InstructionComparator c ) {
- cmp = c;
- }
+
/** Check for equality, delegated to comparator
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/InstructionConstants.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/InstructionConstants.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/InstructionConstants.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/InstructionConstants.java Sat Dec 5 23:22:46 2009
@@ -16,8 +16,6 @@
*/
package org.apache.tomcat.util.bcel.generic;
-import org.apache.tomcat.util.bcel.Constants;
-
/**
* This interface contains shareable instruction objects.
*
@@ -37,250 +35,131 @@
*/
public interface InstructionConstants {
- /** Predefined instruction objects
- */
- public static final Instruction NOP = new NOP();
- public static final Instruction ACONST_NULL = new ACONST_NULL();
- public static final Instruction ICONST_M1 = new ICONST(-1);
- public static final Instruction ICONST_0 = new ICONST(0);
- public static final Instruction ICONST_1 = new ICONST(1);
- public static final Instruction ICONST_2 = new ICONST(2);
- public static final Instruction ICONST_3 = new ICONST(3);
- public static final Instruction ICONST_4 = new ICONST(4);
- public static final Instruction ICONST_5 = new ICONST(5);
- public static final Instruction LCONST_0 = new LCONST(0);
- public static final Instruction LCONST_1 = new LCONST(1);
- public static final Instruction FCONST_0 = new FCONST(0);
- public static final Instruction FCONST_1 = new FCONST(1);
- public static final Instruction FCONST_2 = new FCONST(2);
- public static final Instruction DCONST_0 = new DCONST(0);
- public static final Instruction DCONST_1 = new DCONST(1);
- public static final ArrayInstruction IALOAD = new IALOAD();
- public static final ArrayInstruction LALOAD = new LALOAD();
- public static final ArrayInstruction FALOAD = new FALOAD();
- public static final ArrayInstruction DALOAD = new DALOAD();
- public static final ArrayInstruction AALOAD = new AALOAD();
- public static final ArrayInstruction BALOAD = new BALOAD();
- public static final ArrayInstruction CALOAD = new CALOAD();
- public static final ArrayInstruction SALOAD = new SALOAD();
- public static final ArrayInstruction IASTORE = new IASTORE();
- public static final ArrayInstruction LASTORE = new LASTORE();
- public static final ArrayInstruction FASTORE = new FASTORE();
- public static final ArrayInstruction DASTORE = new DASTORE();
- public static final ArrayInstruction AASTORE = new AASTORE();
- public static final ArrayInstruction BASTORE = new BASTORE();
- public static final ArrayInstruction CASTORE = new CASTORE();
- public static final ArrayInstruction SASTORE = new SASTORE();
- public static final StackInstruction POP = new POP();
- public static final StackInstruction POP2 = new POP2();
- public static final StackInstruction DUP = new DUP();
- public static final StackInstruction DUP_X1 = new DUP_X1();
- public static final StackInstruction DUP_X2 = new DUP_X2();
- public static final StackInstruction DUP2 = new DUP2();
- public static final StackInstruction DUP2_X1 = new DUP2_X1();
- public static final StackInstruction DUP2_X2 = new DUP2_X2();
- public static final StackInstruction SWAP = new SWAP();
- public static final ArithmeticInstruction IADD = new IADD();
- public static final ArithmeticInstruction LADD = new LADD();
- public static final ArithmeticInstruction FADD = new FADD();
- public static final ArithmeticInstruction DADD = new DADD();
- public static final ArithmeticInstruction ISUB = new ISUB();
- public static final ArithmeticInstruction LSUB = new LSUB();
- public static final ArithmeticInstruction FSUB = new FSUB();
- public static final ArithmeticInstruction DSUB = new DSUB();
- public static final ArithmeticInstruction IMUL = new IMUL();
- public static final ArithmeticInstruction LMUL = new LMUL();
- public static final ArithmeticInstruction FMUL = new FMUL();
- public static final ArithmeticInstruction DMUL = new DMUL();
- public static final ArithmeticInstruction IDIV = new IDIV();
- public static final ArithmeticInstruction LDIV = new LDIV();
- public static final ArithmeticInstruction FDIV = new FDIV();
- public static final ArithmeticInstruction DDIV = new DDIV();
- public static final ArithmeticInstruction IREM = new IREM();
- public static final ArithmeticInstruction LREM = new LREM();
- public static final ArithmeticInstruction FREM = new FREM();
- public static final ArithmeticInstruction DREM = new DREM();
- public static final ArithmeticInstruction INEG = new INEG();
- public static final ArithmeticInstruction LNEG = new LNEG();
- public static final ArithmeticInstruction FNEG = new FNEG();
- public static final ArithmeticInstruction DNEG = new DNEG();
- public static final ArithmeticInstruction ISHL = new ISHL();
- public static final ArithmeticInstruction LSHL = new LSHL();
- public static final ArithmeticInstruction ISHR = new ISHR();
- public static final ArithmeticInstruction LSHR = new LSHR();
- public static final ArithmeticInstruction IUSHR = new IUSHR();
- public static final ArithmeticInstruction LUSHR = new LUSHR();
- public static final ArithmeticInstruction IAND = new IAND();
- public static final ArithmeticInstruction LAND = new LAND();
- public static final ArithmeticInstruction IOR = new IOR();
- public static final ArithmeticInstruction LOR = new LOR();
- public static final ArithmeticInstruction IXOR = new IXOR();
- public static final ArithmeticInstruction LXOR = new LXOR();
- public static final ConversionInstruction I2L = new I2L();
- public static final ConversionInstruction I2F = new I2F();
- public static final ConversionInstruction I2D = new I2D();
- public static final ConversionInstruction L2I = new L2I();
- public static final ConversionInstruction L2F = new L2F();
- public static final ConversionInstruction L2D = new L2D();
- public static final ConversionInstruction F2I = new F2I();
- public static final ConversionInstruction F2L = new F2L();
- public static final ConversionInstruction F2D = new F2D();
- public static final ConversionInstruction D2I = new D2I();
- public static final ConversionInstruction D2L = new D2L();
- public static final ConversionInstruction D2F = new D2F();
- public static final ConversionInstruction I2B = new I2B();
- public static final ConversionInstruction I2C = new I2C();
- public static final ConversionInstruction I2S = new I2S();
- public static final Instruction LCMP = new LCMP();
- public static final Instruction FCMPL = new FCMPL();
- public static final Instruction FCMPG = new FCMPG();
- public static final Instruction DCMPL = new DCMPL();
- public static final Instruction DCMPG = new DCMPG();
- public static final ReturnInstruction IRETURN = new IRETURN();
- public static final ReturnInstruction LRETURN = new LRETURN();
- public static final ReturnInstruction FRETURN = new FRETURN();
- public static final ReturnInstruction DRETURN = new DRETURN();
- public static final ReturnInstruction ARETURN = new ARETURN();
- public static final ReturnInstruction RETURN = new RETURN();
- public static final Instruction ARRAYLENGTH = new ARRAYLENGTH();
- public static final Instruction ATHROW = new ATHROW();
- public static final Instruction MONITORENTER = new MONITORENTER();
- public static final Instruction MONITOREXIT = new MONITOREXIT();
- /** You can use these constants in multiple places safely, if you can guarantee
- * that you will never alter their internal values, e.g. call setIndex().
- */
- public static final LocalVariableInstruction THIS = new ALOAD(0);
- public static final LocalVariableInstruction ALOAD_0 = THIS;
- public static final LocalVariableInstruction ALOAD_1 = new ALOAD(1);
- public static final LocalVariableInstruction ALOAD_2 = new ALOAD(2);
- public static final LocalVariableInstruction ILOAD_0 = new ILOAD(0);
- public static final LocalVariableInstruction ILOAD_1 = new ILOAD(1);
- public static final LocalVariableInstruction ILOAD_2 = new ILOAD(2);
- public static final LocalVariableInstruction ASTORE_0 = new ASTORE(0);
- public static final LocalVariableInstruction ASTORE_1 = new ASTORE(1);
- public static final LocalVariableInstruction ASTORE_2 = new ASTORE(2);
- public static final LocalVariableInstruction ISTORE_0 = new ISTORE(0);
- public static final LocalVariableInstruction ISTORE_1 = new ISTORE(1);
- public static final LocalVariableInstruction ISTORE_2 = new ISTORE(2);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/** Get object via its opcode, for immutable instructions like
* branch instructions entries are set to null.
*/
public static final Instruction[] INSTRUCTIONS = new Instruction[256];
- /** Interfaces may have no static initializers, so we simulate this
- * with an inner class.
- */
- static final Clinit bla = new Clinit();
-
- static class Clinit {
+
- Clinit() {
- INSTRUCTIONS[Constants.NOP] = NOP;
- INSTRUCTIONS[Constants.ACONST_NULL] = ACONST_NULL;
- INSTRUCTIONS[Constants.ICONST_M1] = ICONST_M1;
- INSTRUCTIONS[Constants.ICONST_0] = ICONST_0;
- INSTRUCTIONS[Constants.ICONST_1] = ICONST_1;
- INSTRUCTIONS[Constants.ICONST_2] = ICONST_2;
- INSTRUCTIONS[Constants.ICONST_3] = ICONST_3;
- INSTRUCTIONS[Constants.ICONST_4] = ICONST_4;
- INSTRUCTIONS[Constants.ICONST_5] = ICONST_5;
- INSTRUCTIONS[Constants.LCONST_0] = LCONST_0;
- INSTRUCTIONS[Constants.LCONST_1] = LCONST_1;
- INSTRUCTIONS[Constants.FCONST_0] = FCONST_0;
- INSTRUCTIONS[Constants.FCONST_1] = FCONST_1;
- INSTRUCTIONS[Constants.FCONST_2] = FCONST_2;
- INSTRUCTIONS[Constants.DCONST_0] = DCONST_0;
- INSTRUCTIONS[Constants.DCONST_1] = DCONST_1;
- INSTRUCTIONS[Constants.IALOAD] = IALOAD;
- INSTRUCTIONS[Constants.LALOAD] = LALOAD;
- INSTRUCTIONS[Constants.FALOAD] = FALOAD;
- INSTRUCTIONS[Constants.DALOAD] = DALOAD;
- INSTRUCTIONS[Constants.AALOAD] = AALOAD;
- INSTRUCTIONS[Constants.BALOAD] = BALOAD;
- INSTRUCTIONS[Constants.CALOAD] = CALOAD;
- INSTRUCTIONS[Constants.SALOAD] = SALOAD;
- INSTRUCTIONS[Constants.IASTORE] = IASTORE;
- INSTRUCTIONS[Constants.LASTORE] = LASTORE;
- INSTRUCTIONS[Constants.FASTORE] = FASTORE;
- INSTRUCTIONS[Constants.DASTORE] = DASTORE;
- INSTRUCTIONS[Constants.AASTORE] = AASTORE;
- INSTRUCTIONS[Constants.BASTORE] = BASTORE;
- INSTRUCTIONS[Constants.CASTORE] = CASTORE;
- INSTRUCTIONS[Constants.SASTORE] = SASTORE;
- INSTRUCTIONS[Constants.POP] = POP;
- INSTRUCTIONS[Constants.POP2] = POP2;
- INSTRUCTIONS[Constants.DUP] = DUP;
- INSTRUCTIONS[Constants.DUP_X1] = DUP_X1;
- INSTRUCTIONS[Constants.DUP_X2] = DUP_X2;
- INSTRUCTIONS[Constants.DUP2] = DUP2;
- INSTRUCTIONS[Constants.DUP2_X1] = DUP2_X1;
- INSTRUCTIONS[Constants.DUP2_X2] = DUP2_X2;
- INSTRUCTIONS[Constants.SWAP] = SWAP;
- INSTRUCTIONS[Constants.IADD] = IADD;
- INSTRUCTIONS[Constants.LADD] = LADD;
- INSTRUCTIONS[Constants.FADD] = FADD;
- INSTRUCTIONS[Constants.DADD] = DADD;
- INSTRUCTIONS[Constants.ISUB] = ISUB;
- INSTRUCTIONS[Constants.LSUB] = LSUB;
- INSTRUCTIONS[Constants.FSUB] = FSUB;
- INSTRUCTIONS[Constants.DSUB] = DSUB;
- INSTRUCTIONS[Constants.IMUL] = IMUL;
- INSTRUCTIONS[Constants.LMUL] = LMUL;
- INSTRUCTIONS[Constants.FMUL] = FMUL;
- INSTRUCTIONS[Constants.DMUL] = DMUL;
- INSTRUCTIONS[Constants.IDIV] = IDIV;
- INSTRUCTIONS[Constants.LDIV] = LDIV;
- INSTRUCTIONS[Constants.FDIV] = FDIV;
- INSTRUCTIONS[Constants.DDIV] = DDIV;
- INSTRUCTIONS[Constants.IREM] = IREM;
- INSTRUCTIONS[Constants.LREM] = LREM;
- INSTRUCTIONS[Constants.FREM] = FREM;
- INSTRUCTIONS[Constants.DREM] = DREM;
- INSTRUCTIONS[Constants.INEG] = INEG;
- INSTRUCTIONS[Constants.LNEG] = LNEG;
- INSTRUCTIONS[Constants.FNEG] = FNEG;
- INSTRUCTIONS[Constants.DNEG] = DNEG;
- INSTRUCTIONS[Constants.ISHL] = ISHL;
- INSTRUCTIONS[Constants.LSHL] = LSHL;
- INSTRUCTIONS[Constants.ISHR] = ISHR;
- INSTRUCTIONS[Constants.LSHR] = LSHR;
- INSTRUCTIONS[Constants.IUSHR] = IUSHR;
- INSTRUCTIONS[Constants.LUSHR] = LUSHR;
- INSTRUCTIONS[Constants.IAND] = IAND;
- INSTRUCTIONS[Constants.LAND] = LAND;
- INSTRUCTIONS[Constants.IOR] = IOR;
- INSTRUCTIONS[Constants.LOR] = LOR;
- INSTRUCTIONS[Constants.IXOR] = IXOR;
- INSTRUCTIONS[Constants.LXOR] = LXOR;
- INSTRUCTIONS[Constants.I2L] = I2L;
- INSTRUCTIONS[Constants.I2F] = I2F;
- INSTRUCTIONS[Constants.I2D] = I2D;
- INSTRUCTIONS[Constants.L2I] = L2I;
- INSTRUCTIONS[Constants.L2F] = L2F;
- INSTRUCTIONS[Constants.L2D] = L2D;
- INSTRUCTIONS[Constants.F2I] = F2I;
- INSTRUCTIONS[Constants.F2L] = F2L;
- INSTRUCTIONS[Constants.F2D] = F2D;
- INSTRUCTIONS[Constants.D2I] = D2I;
- INSTRUCTIONS[Constants.D2L] = D2L;
- INSTRUCTIONS[Constants.D2F] = D2F;
- INSTRUCTIONS[Constants.I2B] = I2B;
- INSTRUCTIONS[Constants.I2C] = I2C;
- INSTRUCTIONS[Constants.I2S] = I2S;
- INSTRUCTIONS[Constants.LCMP] = LCMP;
- INSTRUCTIONS[Constants.FCMPL] = FCMPL;
- INSTRUCTIONS[Constants.FCMPG] = FCMPG;
- INSTRUCTIONS[Constants.DCMPL] = DCMPL;
- INSTRUCTIONS[Constants.DCMPG] = DCMPG;
- INSTRUCTIONS[Constants.IRETURN] = IRETURN;
- INSTRUCTIONS[Constants.LRETURN] = LRETURN;
- INSTRUCTIONS[Constants.FRETURN] = FRETURN;
- INSTRUCTIONS[Constants.DRETURN] = DRETURN;
- INSTRUCTIONS[Constants.ARETURN] = ARETURN;
- INSTRUCTIONS[Constants.RETURN] = RETURN;
- INSTRUCTIONS[Constants.ARRAYLENGTH] = ARRAYLENGTH;
- INSTRUCTIONS[Constants.ATHROW] = ATHROW;
- INSTRUCTIONS[Constants.MONITORENTER] = MONITORENTER;
- INSTRUCTIONS[Constants.MONITOREXIT] = MONITOREXIT;
- }
- }
+
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/InstructionHandle.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/InstructionHandle.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/InstructionHandle.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/InstructionHandle.java Sat Dec 5 23:22:46 2009
@@ -16,8 +16,6 @@
*/
package org.apache.tomcat.util.bcel.generic;
-import java.util.Collection;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -83,16 +81,7 @@
}
- /**
- * Temporarily swap the current instruction, without disturbing
- * anything. Meant to be used by a debugger, implementing
- * breakpoints. Current instruction is returned.
- */
- public Instruction swapInstruction( Instruction i ) {
- Instruction oldInstruction = instruction;
- instruction = i;
- return oldInstruction;
- }
+
/*private*/protected InstructionHandle(Instruction i) {
@@ -157,27 +146,10 @@
}
- /**
- * Delete contents, i.e., remove user access and make handle reusable.
- */
- void dispose() {
- next = prev = null;
- instruction.dispose();
- instruction = null;
- i_position = -1;
- attributes = null;
- removeAllTargeters();
- addHandle();
- }
+
- /** Remove all targeters, if any.
- */
- public void removeAllTargeters() {
- if (targeters != null) {
- targeters.clear();
- }
- }
+
/**
@@ -202,22 +174,10 @@
}
- public boolean hasTargeters() {
- return (targeters != null) && (targeters.size() > 0);
- }
+
- /**
- * @return null, if there are no targeters
- */
- public InstructionTargeter[] getTargeters() {
- if (!hasTargeters()) {
- return new InstructionTargeter[0];
- }
- InstructionTargeter[] t = new InstructionTargeter[targeters.size()];
- targeters.toArray(t);
- return t;
- }
+
/** @return a (verbose) string representation of the contained instruction.
@@ -234,48 +194,14 @@
}
- /** Add an attribute to an instruction handle.
- *
- * @param key the key object to store/retrieve the attribute
- * @param attr the attribute to associate with this handle
- */
- public void addAttribute( Object key, Object attr ) {
- if (attributes == null) {
- attributes = new HashMap(3);
- }
- attributes.put(key, attr);
- }
+
- /** Delete an attribute of an instruction handle.
- *
- * @param key the key object to retrieve the attribute
- */
- public void removeAttribute( Object key ) {
- if (attributes != null) {
- attributes.remove(key);
- }
- }
+
- /** Get attribute of an instruction handle.
- *
- * @param key the key object to store/retrieve the attribute
- */
- public Object getAttribute( Object key ) {
- if (attributes != null) {
- return attributes.get(key);
- }
- return null;
- }
+
- /** @return all attributes associated with this handle
- */
- public Collection getAttributes() {
- if (attributes == null) {
- attributes = new HashMap(3);
- }
- return attributes.values();
- }
+
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/InstructionList.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/InstructionList.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/InstructionList.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/InstructionList.java Sat Dec 5 23:22:46 2009
@@ -16,20 +16,9 @@
*/
package org.apache.tomcat.util.bcel.generic;
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-
import org.apache.tomcat.util.bcel.Constants;
-import org.apache.tomcat.util.bcel.classfile.Constant;
-import org.apache.tomcat.util.bcel.util.ByteSequence;
/**
* This class is a container for a list of <a
@@ -64,33 +53,13 @@
}
- /**
- * Create instruction list containing one instruction.
- * @param i initial instruction
- */
- public InstructionList(Instruction i) {
- append(i);
- }
+
- /**
- * Create instruction list containing one instruction.
- * @param i initial instruction
- */
- public InstructionList(BranchInstruction i) {
- append(i);
- }
+
- /**
- * Initialize list with (nonnull) compound instruction. Consumes argument
- * list, i.e., it becomes empty.
- *
- * @param c compound instruction (list)
- */
- public InstructionList(CompoundInstruction c) {
- append(c.getInstructionList());
- }
+
/**
@@ -131,94 +100,10 @@
}
- /**
- * Get instruction handle for instruction at byte code position pos.
- * This only works properly, if the list is freshly initialized from a byte array or
- * setPositions() has been called before this method.
- *
- * @param pos byte code position to search for
- * @return target position's instruction handle if available
- */
- public InstructionHandle findHandle( int pos ) {
- int[] positions = byte_positions;
- InstructionHandle ih = start;
- for (int i = 0; i < length; i++) {
- if(positions[i] == pos) {
- return ih;
- }
- ih = ih.next;
- }
- return null;
- }
+
- /**
- * Initialize instruction list from byte array.
- *
- * @param code byte array containing the instructions
- */
- public InstructionList(byte[] code) {
- ByteSequence bytes = new ByteSequence(code);
- InstructionHandle[] ihs = new InstructionHandle[code.length];
- int[] pos = new int[code.length]; // Can't be more than that
- int count = 0; // Contains actual length
- /* Pass 1: Create an object for each byte code and append them
- * to the list.
- */
- try {
- while (bytes.available() > 0) {
- // Remember byte offset and associate it with the instruction
- int off = bytes.getIndex();
- pos[count] = off;
- /* Read one instruction from the byte stream, the byte position is set
- * accordingly.
- */
- Instruction i = Instruction.readInstruction(bytes);
- InstructionHandle ih;
- if (i instanceof BranchInstruction) {
- ih = append((BranchInstruction) i);
- } else {
- ih = append(i);
- }
- ih.setPosition(off);
- ihs[count] = ih;
- count++;
- }
- } catch (IOException e) {
- throw new ClassGenException(e.toString(), e);
- }
- byte_positions = new int[count]; // Trim to proper size
- System.arraycopy(pos, 0, byte_positions, 0, count);
- /* Pass 2: Look for BranchInstruction and update their targets, i.e.,
- * convert offsets to instruction handles.
- */
- for (int i = 0; i < count; i++) {
- if (ihs[i] instanceof BranchHandle) {
- BranchInstruction bi = (BranchInstruction) ihs[i].instruction;
- int target = bi.position + bi.getIndex(); /* Byte code position:
- * relative -> absolute. */
- // Search for target position
- InstructionHandle ih = findHandle(ihs, pos, count, target);
- if (ih == null) {
- throw new ClassGenException("Couldn't find target for branch: " + bi);
- }
- bi.setTarget(ih); // Update target
- // If it is a Select instruction, update all branch targets
- if (bi instanceof Select) { // Either LOOKUPSWITCH or TABLESWITCH
- Select s = (Select) bi;
- int[] indices = s.getIndices();
- for (int j = 0; j < indices.length; j++) {
- target = bi.position + indices[j];
- ih = findHandle(ihs, pos, count, target);
- if (ih == null) {
- throw new ClassGenException("Couldn't find target for switch: " + bi);
- }
- s.setTarget(j, ih); // Update target
- }
- }
- }
- }
- }
+
/**
@@ -251,47 +136,10 @@
}
- /**
- * Append another list after instruction i contained in this list.
- * Consumes argument list, i.e., it becomes empty.
- *
- * @param i where to append the instruction list
- * @param il Instruction list to append to this one
- * @return instruction handle pointing to the <B>first</B> appended instruction
- */
- public InstructionHandle append( Instruction i, InstructionList il ) {
- InstructionHandle ih;
- if ((ih = findInstruction2(i)) == null) {
- throw new ClassGenException("Instruction " + i + " is not contained in this list.");
- }
- return append(ih, il);
- }
+
- /**
- * Append another list to this one.
- * Consumes argument list, i.e., it becomes empty.
- *
- * @param il list to append to end of this list
- * @return instruction handle of the <B>first</B> appended instruction
- */
- public InstructionHandle append( InstructionList il ) {
- if (il == null) {
- throw new ClassGenException("Appending null InstructionList");
- }
- if (il.isEmpty()) {
- return null;
- }
- if (isEmpty()) {
- start = il.start;
- end = il.end;
- length = il.length;
- il.clear();
- return start;
- } else {
- return append(end, il); // was end.instruction
- }
- }
+
/**
@@ -339,455 +187,61 @@
}
- /**
- * Append a single instruction j after another instruction i, which
- * must be in this list of course!
- *
- * @param i Instruction in list
- * @param j Instruction to append after i in list
- * @return instruction handle of the first appended instruction
- */
- public InstructionHandle append( Instruction i, Instruction j ) {
- return append(i, new InstructionList(j));
- }
+
- /**
- * Append a compound instruction, after instruction i.
- *
- * @param i Instruction in list
- * @param c The composite instruction (containing an InstructionList)
- * @return instruction handle of the first appended instruction
- */
- public InstructionHandle append( Instruction i, CompoundInstruction c ) {
- return append(i, c.getInstructionList());
- }
+
- /**
- * Append a compound instruction.
- *
- * @param c The composite instruction (containing an InstructionList)
- * @return instruction handle of the first appended instruction
- */
- public InstructionHandle append( CompoundInstruction c ) {
- return append(c.getInstructionList());
- }
+
- /**
- * Append a compound instruction.
- *
- * @param ih where to append the instruction list
- * @param c The composite instruction (containing an InstructionList)
- * @return instruction handle of the first appended instruction
- */
- public InstructionHandle append( InstructionHandle ih, CompoundInstruction c ) {
- return append(ih, c.getInstructionList());
- }
+
- /**
- * Append an instruction after instruction (handle) ih contained in this list.
- *
- * @param ih where to append the instruction list
- * @param i Instruction to append
- * @return instruction handle pointing to the <B>first</B> appended instruction
- */
- public InstructionHandle append( InstructionHandle ih, Instruction i ) {
- return append(ih, new InstructionList(i));
- }
+
- /**
- * Append an instruction after instruction (handle) ih contained in this list.
- *
- * @param ih where to append the instruction list
- * @param i Instruction to append
- * @return instruction handle pointing to the <B>first</B> appended instruction
- */
- public BranchHandle append( InstructionHandle ih, BranchInstruction i ) {
- BranchHandle bh = BranchHandle.getBranchHandle(i);
- InstructionList il = new InstructionList();
- il.append(bh);
- append(ih, il);
- return bh;
- }
+
- /**
- * Insert another list before Instruction handle ih contained in this list.
- * Consumes argument list, i.e., it becomes empty.
- *
- * @param ih where to append the instruction list
- * @param il Instruction list to insert
- * @return instruction handle of the first inserted instruction
- */
- public InstructionHandle insert( InstructionHandle ih, InstructionList il ) {
- if (il == null) {
- throw new ClassGenException("Inserting null InstructionList");
- }
- if (il.isEmpty()) {
- return ih;
- }
- InstructionHandle prev = ih.prev, ret = il.start;
- ih.prev = il.end;
- il.end.next = ih;
- il.start.prev = prev;
- if (prev != null) {
- prev.next = il.start;
- } else {
- start = il.start; // Update start ...
- }
- length += il.length; // Update length
- il.clear();
- return ret;
- }
+
- /**
- * Insert another list.
- *
- * @param il list to insert before start of this list
- * @return instruction handle of the first inserted instruction
- */
- public InstructionHandle insert( InstructionList il ) {
- if (isEmpty()) {
- append(il); // Code is identical for this case
- return start;
- } else {
- return insert(start, il);
- }
- }
+
- /**
- * Insert an instruction at start of this list.
- *
- * @param ih instruction to insert
- */
- private void insert( InstructionHandle ih ) {
- if (isEmpty()) {
- start = end = ih;
- ih.next = ih.prev = null;
- } else {
- start.prev = ih;
- ih.next = start;
- ih.prev = null;
- start = ih;
- }
- length++;
- }
+
- /**
- * Insert another list before Instruction i contained in this list.
- * Consumes argument list, i.e., it becomes empty.
- *
- * @param i where to append the instruction list
- * @param il Instruction list to insert
- * @return instruction handle pointing to the first inserted instruction,
- * i.e., il.getStart()
- */
- public InstructionHandle insert( Instruction i, InstructionList il ) {
- InstructionHandle ih;
- if ((ih = findInstruction1(i)) == null) {
- throw new ClassGenException("Instruction " + i + " is not contained in this list.");
- }
- return insert(ih, il);
- }
+
- /**
- * Insert an instruction at start of this list.
- *
- * @param i instruction to insert
- * @return instruction handle of the inserted instruction
- */
- public InstructionHandle insert( Instruction i ) {
- InstructionHandle ih = InstructionHandle.getInstructionHandle(i);
- insert(ih);
- return ih;
- }
+
- /**
- * Insert a branch instruction at start of this list.
- *
- * @param i branch instruction to insert
- * @return branch instruction handle of the appended instruction
- */
- public BranchHandle insert( BranchInstruction i ) {
- BranchHandle ih = BranchHandle.getBranchHandle(i);
- insert(ih);
- return ih;
- }
+
- /**
- * Insert a single instruction j before another instruction i, which
- * must be in this list of course!
- *
- * @param i Instruction in list
- * @param j Instruction to insert before i in list
- * @return instruction handle of the first inserted instruction
- */
- public InstructionHandle insert( Instruction i, Instruction j ) {
- return insert(i, new InstructionList(j));
- }
+
- /**
- * Insert a compound instruction before instruction i.
- *
- * @param i Instruction in list
- * @param c The composite instruction (containing an InstructionList)
- * @return instruction handle of the first inserted instruction
- */
- public InstructionHandle insert( Instruction i, CompoundInstruction c ) {
- return insert(i, c.getInstructionList());
- }
+
- /**
- * Insert a compound instruction.
- *
- * @param c The composite instruction (containing an InstructionList)
- * @return instruction handle of the first inserted instruction
- */
- public InstructionHandle insert( CompoundInstruction c ) {
- return insert(c.getInstructionList());
- }
+
- /**
- * Insert an instruction before instruction (handle) ih contained in this list.
- *
- * @param ih where to insert to the instruction list
- * @param i Instruction to insert
- * @return instruction handle of the first inserted instruction
- */
- public InstructionHandle insert( InstructionHandle ih, Instruction i ) {
- return insert(ih, new InstructionList(i));
- }
+
- /**
- * Insert a compound instruction.
- *
- * @param ih where to insert the instruction list
- * @param c The composite instruction (containing an InstructionList)
- * @return instruction handle of the first inserted instruction
- */
- public InstructionHandle insert( InstructionHandle ih, CompoundInstruction c ) {
- return insert(ih, c.getInstructionList());
- }
+
- /**
- * Insert an instruction before instruction (handle) ih contained in this list.
- *
- * @param ih where to insert to the instruction list
- * @param i Instruction to insert
- * @return instruction handle of the first inserted instruction
- */
- public BranchHandle insert( InstructionHandle ih, BranchInstruction i ) {
- BranchHandle bh = BranchHandle.getBranchHandle(i);
- InstructionList il = new InstructionList();
- il.append(bh);
- insert(ih, il);
- return bh;
- }
+
- /**
- * Take all instructions (handles) from "start" to "end" and append them after the
- * new location "target". Of course, "end" must be after "start" and target must
- * not be located withing this range. If you want to move something to the start of
- * the list use null as value for target.<br>
- * Any instruction targeters pointing to handles within the block, keep their targets.
- *
- * @param start of moved block
- * @param end of moved block
- * @param target of moved block
- */
- public void move( InstructionHandle start, InstructionHandle end, InstructionHandle target ) {
- // Step 1: Check constraints
- if ((start == null) || (end == null)) {
- throw new ClassGenException("Invalid null handle: From " + start + " to " + end);
- }
- if ((target == start) || (target == end)) {
- throw new ClassGenException("Invalid range: From " + start + " to " + end
- + " contains target " + target);
- }
- for (InstructionHandle ih = start; ih != end.next; ih = ih.next) {
- if (ih == null) {
- throw new ClassGenException("Invalid range: From " + start + " to " + end);
- } else if (ih == target) {
- throw new ClassGenException("Invalid range: From " + start + " to " + end
- + " contains target " + target);
- }
- }
- // Step 2: Temporarily remove the given instructions from the list
- InstructionHandle prev = start.prev, next = end.next;
- if (prev != null) {
- prev.next = next;
- } else {
- this.start = next;
- }
- if (next != null) {
- next.prev = prev;
- } else {
- this.end = prev;
- }
- start.prev = end.next = null;
- // Step 3: append after target
- if (target == null) { // append to start of list
- if (this.start != null) {
- this.start.prev = end;
- }
- end.next = this.start;
- this.start = start;
- } else {
- next = target.next;
- target.next = start;
- start.prev = target;
- end.next = next;
- if (next != null) {
- next.prev = end;
- } else {
- this.end = end;
- }
- }
- }
-
-
- /**
- * Move a single instruction (handle) to a new location.
- *
- * @param ih moved instruction
- * @param target new location of moved instruction
- */
- public void move( InstructionHandle ih, InstructionHandle target ) {
- move(ih, ih, target);
- }
-
-
- /**
- * Remove from instruction `prev' to instruction `next' both contained
- * in this list. Throws TargetLostException when one of the removed instruction handles
- * is still being targeted.
- *
- * @param prev where to start deleting (predecessor, exclusive)
- * @param next where to end deleting (successor, exclusive)
- */
- private void remove( InstructionHandle prev, InstructionHandle next )
- throws TargetLostException {
- InstructionHandle first, last; // First and last deleted instruction
- if ((prev == null) && (next == null)) {
- first = start;
- last = end;
- start = end = null;
- } else {
- if (prev == null) { // At start of list
- first = start;
- start = next;
- } else {
- first = prev.next;
- prev.next = next;
- }
- if (next == null) { // At end of list
- last = end;
- end = prev;
- } else {
- last = next.prev;
- next.prev = prev;
- }
- }
- first.prev = null; // Completely separated from rest of list
- last.next = null;
- List target_vec = new ArrayList();
- for (InstructionHandle ih = first; ih != null; ih = ih.next) {
- ih.getInstruction().dispose(); // e.g. BranchInstructions release their targets
- }
- StringBuffer buf = new StringBuffer("{ ");
- for (InstructionHandle ih = first; ih != null; ih = next) {
- next = ih.next;
- length--;
- if (ih.hasTargeters()) { // Still got targeters?
- target_vec.add(ih);
- buf.append(ih.toString(true) + " ");
- ih.next = ih.prev = null;
- } else {
- ih.dispose();
- }
- }
- buf.append("}");
- if (!target_vec.isEmpty()) {
- InstructionHandle[] targeted = new InstructionHandle[target_vec.size()];
- target_vec.toArray(targeted);
- throw new TargetLostException(targeted, buf.toString());
- }
- }
-
-
- /**
- * Remove instruction from this list. The corresponding Instruction
- * handles must not be reused!
- *
- * @param ih instruction (handle) to remove
- */
- public void delete( InstructionHandle ih ) throws TargetLostException {
- remove(ih.prev, ih.next);
- }
-
-
- /**
- * Remove instruction from this list. The corresponding Instruction
- * handles must not be reused!
- *
- * @param i instruction to remove
- */
- public void delete( Instruction i ) throws TargetLostException {
- InstructionHandle ih;
- if ((ih = findInstruction1(i)) == null) {
- throw new ClassGenException("Instruction " + i + " is not contained in this list.");
- }
- delete(ih);
- }
-
-
- /**
- * Remove instructions from instruction `from' to instruction `to' contained
- * in this list. The user must ensure that `from' is an instruction before
- * `to', or risk havoc. The corresponding Instruction handles must not be reused!
- *
- * @param from where to start deleting (inclusive)
- * @param to where to end deleting (inclusive)
- */
- public void delete( InstructionHandle from, InstructionHandle to ) throws TargetLostException {
- remove(from.prev, to.next);
- }
-
-
- /**
- * Remove instructions from instruction `from' to instruction `to' contained
- * in this list. The user must ensure that `from' is an instruction before
- * `to', or risk havoc. The corresponding Instruction handles must not be reused!
- *
- * @param from where to start deleting (inclusive)
- * @param to where to end deleting (inclusive)
- */
- public void delete( Instruction from, Instruction to ) throws TargetLostException {
- InstructionHandle from_ih, to_ih;
- if ((from_ih = findInstruction1(from)) == null) {
- throw new ClassGenException("Instruction " + from + " is not contained in this list.");
- }
- if ((to_ih = findInstruction2(to)) == null) {
- throw new ClassGenException("Instruction " + to + " is not contained in this list.");
- }
- delete(from_ih, to_ih);
- }
+
/**
@@ -806,35 +260,6 @@
}
- /**
- * Search for given Instruction reference, start at end of list
- *
- * @param i instruction to search for
- * @return instruction found on success, null otherwise
- */
- private InstructionHandle findInstruction2( Instruction i ) {
- for (InstructionHandle ih = end; ih != null; ih = ih.prev) {
- if (ih.instruction == i) {
- return ih;
- }
- }
- return null;
- }
-
-
- public boolean contains( InstructionHandle i ) {
- if (i == null) {
- return false;
- }
- for (InstructionHandle ih = start; ih != null; ih = ih.next) {
- if (ih == i) {
- return true;
- }
- }
- return false;
- }
-
-
public boolean contains( Instruction i ) {
return findInstruction1(i) != null;
}
@@ -933,45 +358,10 @@
}
- /**
- * When everything is finished, use this method to convert the instruction
- * list into an array of bytes.
- *
- * @return the byte code ready to be dumped
- */
- public byte[] getByteCode() {
- // Update position indices of instructions
- setPositions();
- ByteArrayOutputStream b = new ByteArrayOutputStream();
- DataOutputStream out = new DataOutputStream(b);
- try {
- for (InstructionHandle ih = start; ih != null; ih = ih.next) {
- Instruction i = ih.instruction;
- i.dump(out); // Traverse list
- }
- } catch (IOException e) {
- System.err.println(e);
- return new byte[0];
- }
- return b.toByteArray();
- }
+
- /**
- * @return an array of instructions without target information for branch instructions.
- */
- public Instruction[] getInstructions() {
- ByteSequence bytes = new ByteSequence(getByteCode());
- List instructions = new ArrayList();
- try {
- while (bytes.available() > 0) {
- instructions.add(Instruction.readInstruction(bytes));
- }
- } catch (IOException e) {
- throw new ClassGenException(e.toString(), e);
- }
- return (Instruction[]) instructions.toArray(new Instruction[instructions.size()]);
- }
+
public String toString() {
@@ -992,122 +382,19 @@
}
- /**
- * @return Enumeration that lists all instructions (handles)
- */
- public Iterator iterator() {
- return new Iterator() {
+
- private InstructionHandle ih = start;
+
- public Object next() throws NoSuchElementException {
- if (ih == null)
- throw new NoSuchElementException();
- InstructionHandle i = ih;
- ih = ih.next;
- return i;
- }
-
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
-
- public boolean hasNext() {
- return ih != null;
- }
- };
- }
-
-
- /**
- * @return array containing all instructions (handles)
- */
- public InstructionHandle[] getInstructionHandles() {
- InstructionHandle[] ihs = new InstructionHandle[length];
- InstructionHandle ih = start;
- for (int i = 0; i < length; i++) {
- ihs[i] = ih;
- ih = ih.next;
- }
- return ihs;
- }
-
- /**
- * Get positions (offsets) of all instructions in the list. This relies on that
- * the list has been freshly created from an byte code array, or that setPositions()
- * has been called. Otherwise this may be inaccurate.
- *
- * @return array containing all instruction's offset in byte code
- */
- public int[] getInstructionPositions() {
- return byte_positions;
- }
+
- /**
- * @return complete, i.e., deep copy of this list
- */
- public InstructionList copy() {
- Map map = new HashMap();
- InstructionList il = new InstructionList();
- /* Pass 1: Make copies of all instructions, append them to the new list
- * and associate old instruction references with the new ones, i.e.,
- * a 1:1 mapping.
- */
- for (InstructionHandle ih = start; ih != null; ih = ih.next) {
- Instruction i = ih.instruction;
- Instruction c = i.copy(); // Use clone for shallow copy
- if (c instanceof BranchInstruction) {
- map.put(ih, il.append((BranchInstruction) c));
- } else {
- map.put(ih, il.append(c));
- }
- }
- /* Pass 2: Update branch targets.
- */
- InstructionHandle ih = start;
- InstructionHandle ch = il.start;
- while (ih != null) {
- Instruction i = ih.instruction;
- Instruction c = ch.instruction;
- if (i instanceof BranchInstruction) {
- BranchInstruction bi = (BranchInstruction) i;
- BranchInstruction bc = (BranchInstruction) c;
- InstructionHandle itarget = bi.getTarget(); // old target
- // New target is in hash map
- bc.setTarget((InstructionHandle) map.get(itarget));
- if (bi instanceof Select) { // Either LOOKUPSWITCH or TABLESWITCH
- InstructionHandle[] itargets = ((Select) bi).getTargets();
- InstructionHandle[] ctargets = ((Select) bc).getTargets();
- for (int j = 0; j < itargets.length; j++) { // Update all targets
- ctargets[j] = (InstructionHandle) map.get(itargets[j]);
- }
- }
- }
- ih = ih.next;
- ch = ch.next;
- }
- return il;
- }
+
- /** Replace all references to the old constant pool with references to the new
- * constant pool
- */
- public void replaceConstantPool( ConstantPoolGen old_cp, ConstantPoolGen new_cp ) {
- for (InstructionHandle ih = start; ih != null; ih = ih.next) {
- Instruction i = ih.instruction;
- if (i instanceof CPInstruction) {
- CPInstruction ci = (CPInstruction) i;
- Constant c = old_cp.getConstant(ci.getIndex());
- ci.setIndex(new_cp.addConstant(c, old_cp));
- }
- }
- }
+
private void clear() {
@@ -1116,22 +403,7 @@
}
- /**
- * Delete contents of list. Provides besser memory utilization,
- * because the system then may reuse the instruction handles. This
- * method is typically called right after
- * <href="MethodGen.html#getMethod()">MethodGen.getMethod()</a>.
- */
- public void dispose() {
- // Traverse in reverse order, because ih.next is overwritten
- for (InstructionHandle ih = end; ih != null; ih = ih.prev) {
- /* Causes BranchInstructions to release target and targeters, because it
- * calls dispose() on the contained instruction.
- */
- ih.dispose();
- }
- clear();
- }
+
/**
@@ -1150,128 +422,28 @@
}
- /**
- * @return length of list (Number of instructions, not bytes)
- */
- public int getLength() {
- return length;
- }
+
- /**
- * @return length of list (Number of instructions, not bytes)
- */
- public int size() {
- return length;
- }
+
- /**
- * Redirect all references from old_target to new_target, i.e., update targets
- * of branch instructions.
- *
- * @param old_target the old target instruction handle
- * @param new_target the new target instruction handle
- */
- public void redirectBranches( InstructionHandle old_target, InstructionHandle new_target ) {
- for (InstructionHandle ih = start; ih != null; ih = ih.next) {
- Instruction i = ih.getInstruction();
- if (i instanceof BranchInstruction) {
- BranchInstruction b = (BranchInstruction) i;
- InstructionHandle target = b.getTarget();
- if (target == old_target) {
- b.setTarget(new_target);
- }
- if (b instanceof Select) { // Either LOOKUPSWITCH or TABLESWITCH
- InstructionHandle[] targets = ((Select) b).getTargets();
- for (int j = 0; j < targets.length; j++) {
- if (targets[j] == old_target) {
- ((Select) b).setTarget(j, new_target);
- }
- }
- }
- }
- }
- }
+
- /**
- * Redirect all references of local variables from old_target to new_target.
- *
- * @param lg array of local variables
- * @param old_target the old target instruction handle
- * @param new_target the new target instruction handle
- * @see MethodGen
- */
- public void redirectLocalVariables( LocalVariableGen[] lg, InstructionHandle old_target,
- InstructionHandle new_target ) {
- for (int i = 0; i < lg.length; i++) {
- InstructionHandle start = lg[i].getStart();
- InstructionHandle end = lg[i].getEnd();
- if (start == old_target) {
- lg[i].setStart(new_target);
- }
- if (end == old_target) {
- lg[i].setEnd(new_target);
- }
- }
- }
+
- /**
- * Redirect all references of exception handlers from old_target to new_target.
- *
- * @param exceptions array of exception handlers
- * @param old_target the old target instruction handle
- * @param new_target the new target instruction handle
- * @see MethodGen
- */
- public void redirectExceptionHandlers( CodeExceptionGen[] exceptions,
- InstructionHandle old_target, InstructionHandle new_target ) {
- for (int i = 0; i < exceptions.length; i++) {
- if (exceptions[i].getStartPC() == old_target) {
- exceptions[i].setStartPC(new_target);
- }
- if (exceptions[i].getEndPC() == old_target) {
- exceptions[i].setEndPC(new_target);
- }
- if (exceptions[i].getHandlerPC() == old_target) {
- exceptions[i].setHandlerPC(new_target);
- }
- }
- }
+
private List observers;
- /** Add observer for this object.
- */
- public void addObserver( InstructionListObserver o ) {
- if (observers == null) {
- observers = new ArrayList();
- }
- observers.add(o);
- }
+
- /** Remove observer for this object.
- */
- public void removeObserver( InstructionListObserver o ) {
- if (observers != null) {
- observers.remove(o);
- }
- }
+
- /** Call notify() method on all observers. This method is not called
- * automatically whenever the state has changed, but has to be
- * called by the user after he has finished editing the object.
- */
- public void update() {
- if (observers != null) {
- for (Iterator e = observers.iterator(); e.hasNext();) {
- ((InstructionListObserver) e.next()).notify(this);
- }
- }
- }
+
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/InstructionTargeter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/InstructionTargeter.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/InstructionTargeter.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/InstructionTargeter.java Sat Dec 5 23:22:46 2009
@@ -28,8 +28,8 @@
*/
public interface InstructionTargeter {
- public boolean containsTarget( InstructionHandle ih );
+
- public void updateTarget( InstructionHandle old_ih, InstructionHandle new_ih );
+
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/InvokeInstruction.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/InvokeInstruction.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/InvokeInstruction.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/InvokeInstruction.java Sat Dec 5 23:22:46 2009
@@ -38,12 +38,7 @@
}
- /**
- * @param index to constant pool
- */
- protected InvokeInstruction(short opcode, int index) {
- super(opcode, index);
- }
+
/**
@@ -94,11 +89,7 @@
}
- /** @return name of referenced method.
- */
- public String getMethodName( ConstantPoolGen cpg ) {
- return getName(cpg);
- }
+
/** @return return type of referenced method.
@@ -108,9 +99,5 @@
}
- /** @return argument types of referenced method.
- */
- public Type[] getArgumentTypes( ConstantPoolGen cpg ) {
- return Type.getArgumentTypes(getSignature(cpg));
- }
+
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/JSR.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/JSR.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/JSR.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/JSR.java Sat Dec 5 23:22:46 2009
@@ -35,9 +35,7 @@
}
- public JSR(InstructionHandle target) {
- super(org.apache.tomcat.util.bcel.Constants.JSR, target);
- }
+
/**
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/JSR_W.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/JSR_W.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/JSR_W.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/JSR_W.java Sat Dec 5 23:22:46 2009
@@ -36,10 +36,7 @@
}
- public JSR_W(InstructionHandle target) {
- super(org.apache.tomcat.util.bcel.Constants.JSR_W, target);
- length = 5;
- }
+
/**
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/JsrInstruction.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/JsrInstruction.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/JsrInstruction.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/JsrInstruction.java Sat Dec 5 23:22:46 2009
@@ -25,9 +25,7 @@
public abstract class JsrInstruction extends BranchInstruction implements UnconditionalBranch,
TypedInstruction, StackProducer {
- JsrInstruction(short opcode, InstructionHandle target) {
- super(opcode, target);
- }
+
/**
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LDC.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LDC.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LDC.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LDC.java Sat Dec 5 23:22:46 2009
@@ -39,10 +39,7 @@
}
- public LDC(int index) {
- super(org.apache.tomcat.util.bcel.Constants.LDC_W, index);
- setSize();
- }
+
// Adjust to proper size
@@ -89,23 +86,7 @@
}
- public Object getValue( ConstantPoolGen cpg ) {
- org.apache.tomcat.util.bcel.classfile.Constant c = cpg.getConstantPool().getConstant(index);
- switch (c.getTag()) {
- case org.apache.tomcat.util.bcel.Constants.CONSTANT_String:
- int i = ((org.apache.tomcat.util.bcel.classfile.ConstantString) c).getStringIndex();
- c = cpg.getConstantPool().getConstant(i);
- return ((org.apache.tomcat.util.bcel.classfile.ConstantUtf8) c).getBytes();
- case org.apache.tomcat.util.bcel.Constants.CONSTANT_Float:
- return new Float(((org.apache.tomcat.util.bcel.classfile.ConstantFloat) c).getBytes());
- case org.apache.tomcat.util.bcel.Constants.CONSTANT_Integer:
- return new Integer(((org.apache.tomcat.util.bcel.classfile.ConstantInteger) c).getBytes());
- case org.apache.tomcat.util.bcel.Constants.CONSTANT_Class:
- return c;
- default: // Never reached
- throw new RuntimeException("Unknown or invalid constant type at " + index);
- }
- }
+
public Type getType( ConstantPoolGen cpg ) {
@@ -124,7 +105,5 @@
}
- public Class[] getExceptions() {
- return org.apache.tomcat.util.bcel.ExceptionConstants.EXCS_STRING_RESOLUTION;
- }
+
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LDC2_W.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LDC2_W.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LDC2_W.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LDC2_W.java Sat Dec 5 23:22:46 2009
@@ -34,9 +34,7 @@
}
- public LDC2_W(int index) {
- super(org.apache.tomcat.util.bcel.Constants.LDC2_W, index);
- }
+
public Type getType( ConstantPoolGen cpg ) {
@@ -51,15 +49,5 @@
}
- public Number getValue( ConstantPoolGen cpg ) {
- org.apache.tomcat.util.bcel.classfile.Constant c = cpg.getConstantPool().getConstant(index);
- switch (c.getTag()) {
- case org.apache.tomcat.util.bcel.Constants.CONSTANT_Long:
- return new Long(((org.apache.tomcat.util.bcel.classfile.ConstantLong) c).getBytes());
- case org.apache.tomcat.util.bcel.Constants.CONSTANT_Double:
- return new Double(((org.apache.tomcat.util.bcel.classfile.ConstantDouble) c).getBytes());
- default: // Never reached
- throw new RuntimeException("Unknown or invalid constant type at " + index);
- }
- }
+
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LDC_W.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LDC_W.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LDC_W.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LDC_W.java Sat Dec 5 23:22:46 2009
@@ -37,9 +37,7 @@
}
- public LDC_W(int index) {
- super(index);
- }
+
/**
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LOOKUPSWITCH.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LOOKUPSWITCH.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LOOKUPSWITCH.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LOOKUPSWITCH.java Sat Dec 5 23:22:46 2009
@@ -37,12 +37,7 @@
}
- public LOOKUPSWITCH(int[] match, InstructionHandle[] targets, InstructionHandle defaultTarget) {
- super(org.apache.tomcat.util.bcel.Constants.LOOKUPSWITCH, match, targets, defaultTarget);
- length = (short) (9 + match_length * 8); /* alignment remainder assumed
- * 0 here, until dump time. */
- fixed_length = length;
- }
+
/**
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LineNumberGen.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LineNumberGen.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LineNumberGen.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LineNumberGen.java Sat Dec 5 23:22:46 2009
@@ -44,25 +44,10 @@
}
- /**
- * @return true, if ih is target of this line number
- */
- public boolean containsTarget( InstructionHandle ih ) {
- return this.ih == ih;
- }
+
- /**
- * @param old_ih old target
- * @param new_ih new target
- */
- public void updateTarget( InstructionHandle old_ih, InstructionHandle new_ih ) {
- if (old_ih != ih) {
- throw new ClassGenException("Not targeting " + old_ih + ", but " + ih + "}");
- } else {
- setInstruction(new_ih);
- }
- }
+
/**
@@ -92,9 +77,7 @@
}
- public InstructionHandle getInstruction() {
- return ih;
- }
+
public void setSourceLine( int src_line ) {
@@ -102,7 +85,5 @@
}
- public int getSourceLine() {
- return src_line;
- }
+
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LoadClass.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LoadClass.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LoadClass.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LoadClass.java Sat Dec 5 23:22:46 2009
@@ -25,26 +25,8 @@
*/
public interface LoadClass {
- /**
- * Returns the ObjectType of the referenced class or interface
- * that may be loaded and resolved.
- * @return object type that may be loaded or null if a primitive is
- * referenced
- */
- public ObjectType getLoadClassType( ConstantPoolGen cpg );
+
- /**
- * Returns the type associated with this instruction.
- * LoadClass instances are always typed, but this type
- * does not always refer to the type of the class or interface
- * that it possibly forces to load. For example, GETFIELD would
- * return the type of the field and not the type of the class
- * where the field is defined.
- * If no class is forced to be loaded, <B>null</B> is returned.
- * An example for this is an ANEWARRAY instruction that creates
- * an int[][].
- * @see #getLoadClassType(ConstantPoolGen)
- */
- public Type getType( ConstantPoolGen cpg );
+
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LocalVariableGen.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LocalVariableGen.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LocalVariableGen.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LocalVariableGen.java Sat Dec 5 23:22:46 2009
@@ -16,7 +16,6 @@
*/
package org.apache.tomcat.util.bcel.generic;
-import org.apache.tomcat.util.bcel.Constants;
import org.apache.tomcat.util.bcel.classfile.LocalVariable;
/**
@@ -39,27 +38,7 @@
private InstructionHandle start, end;
- /**
- * Generate a local variable that with index `index'. Note that double and long
- * variables need two indexs. Index indices have to be provided by the user.
- *
- * @param index index of local variable
- * @param name its name
- * @param type its type
- * @param start from where the instruction is valid (null means from the start)
- * @param end until where the instruction is valid (null means to the end)
- */
- public LocalVariableGen(int index, String name, Type type, InstructionHandle start,
- InstructionHandle end) {
- if ((index < 0) || (index > Constants.MAX_SHORT)) {
- throw new ClassGenException("Invalid index index: " + index);
- }
- this.name = name;
- this.type = type;
- this.index = index;
- setStart(start);
- setEnd(end);
- }
+
/**
@@ -89,9 +68,7 @@
}
- public void setIndex( int index ) {
- this.index = index;
- }
+
public int getIndex() {
@@ -114,9 +91,7 @@
}
- public Type getType() {
- return type;
- }
+
public InstructionHandle getStart() {
@@ -141,33 +116,10 @@
}
- /**
- * @param old_ih old target, either start or end
- * @param new_ih new target
- */
- public void updateTarget( InstructionHandle old_ih, InstructionHandle new_ih ) {
- boolean targeted = false;
- if (start == old_ih) {
- targeted = true;
- setStart(new_ih);
- }
- if (end == old_ih) {
- targeted = true;
- setEnd(new_ih);
- }
- if (!targeted) {
- throw new ClassGenException("Not targeting " + old_ih + ", but {" + start + ", " + end
- + "}");
- }
- }
+
- /**
- * @return true, if ih is target of this variable
- */
- public boolean containsTarget( InstructionHandle ih ) {
- return (start == ih) || (end == ih);
- }
+
/** @return a hash code value for the object.
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LocalVariableInstruction.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LocalVariableInstruction.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LocalVariableInstruction.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/LocalVariableInstruction.java Sat Dec 5 23:22:46 2009
@@ -163,11 +163,7 @@
}
- /** @return canonical tag for instruction, e.g., ALOAD for ALOAD_0
- */
- public short getCanonicalTag() {
- return canon_tag;
- }
+
/**
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/MULTIANEWARRAY.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/MULTIANEWARRAY.java?rev=887610&r1=887609&r2=887610&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/MULTIANEWARRAY.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/MULTIANEWARRAY.java Sat Dec 5 23:22:46 2009
@@ -18,7 +18,6 @@
import java.io.DataOutputStream;
import java.io.IOException;
-import org.apache.tomcat.util.bcel.ExceptionConstants;
import org.apache.tomcat.util.bcel.classfile.ConstantPool;
import org.apache.tomcat.util.bcel.util.ByteSequence;
@@ -43,14 +42,7 @@
}
- public MULTIANEWARRAY(int index, short dimensions) {
- super(org.apache.tomcat.util.bcel.Constants.MULTIANEWARRAY, index);
- if (dimensions < 1) {
- throw new ClassGenException("Invalid dimensions value: " + dimensions);
- }
- this.dimensions = dimensions;
- length = 4;
- }
+
/**
@@ -74,12 +66,7 @@
}
- /**
- * @return number of dimensions to be created
- */
- public final short getDimensions() {
- return dimensions;
- }
+
/**
@@ -108,21 +95,8 @@
}
- public Class[] getExceptions() {
- Class[] cs = new Class[2 + ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length];
- System.arraycopy(ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION, 0, cs, 0,
- ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length);
- cs[ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length + 1] = ExceptionConstants.NEGATIVE_ARRAY_SIZE_EXCEPTION;
- cs[ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length] = ExceptionConstants.ILLEGAL_ACCESS_ERROR;
- return cs;
- }
+
- public ObjectType getLoadClassType( ConstantPoolGen cpg ) {
- Type t = getType(cpg);
- if (t instanceof ArrayType) {
- t = ((ArrayType) t).getBasicType();
- }
- return (t instanceof ObjectType) ? (ObjectType) t : null;
- }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org