Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/Unknown.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/Unknown.java?rev=887613&r1=887612&r2=887613&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/Unknown.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/Unknown.java Sun Dec 6 00:19:52 2009 @@ -88,18 +88,6 @@ /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept( Visitor v ) { - v.visitUnknown(this); - } - - - /** * Dump unknown bytes to file stream. * * @param file Output file stream
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/Utility.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/Utility.java?rev=887613&r1=887612&r2=887613&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/Utility.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/Utility.java Sun Dec 6 00:19:52 2009 @@ -16,11 +16,7 @@ */ package org.apache.tomcat.util.bcel.classfile; -import java.io.FilterReader; -import java.io.FilterWriter; import java.io.IOException; -import java.io.Reader; -import java.io.Writer; import org.apache.tomcat.util.bcel.Constants; import org.apache.tomcat.util.bcel.util.ByteSequence; @@ -855,7 +851,6 @@ private static final int FREE_CHARS = 48; static int[] CHAR_MAP = new int[FREE_CHARS]; static int[] MAP_CHAR = new int[256]; // Reverse map - private static final char ESCAPE_CHAR = '$'; static { int j = 0; for (int i = 'A'; i <= 'Z'; i++) { @@ -875,93 +870,6 @@ MAP_CHAR['_'] = j; } - /** Decode characters into bytes. - * Used by <a href="Utility.html#decode(java.lang.String, boolean)">decode()</a> - */ - private static class JavaReader extends FilterReader { - - public JavaReader(Reader in) { - super(in); - } - - - public int read() throws IOException { - int b = in.read(); - if (b != ESCAPE_CHAR) { - return b; - } - int i = in.read(); - if (i < 0) { - return -1; - } - if (((i >= '0') && (i <= '9')) || ((i >= 'a') && (i <= 'f'))) { // Normal escape - int j = in.read(); - if (j < 0) { - return -1; - } - char[] tmp = { - (char) i, (char) j - }; - int s = Integer.parseInt(new String(tmp), 16); - return s; - } - return MAP_CHAR[i]; - } - - - public int read( char[] cbuf, int off, int len ) throws IOException { - for (int i = 0; i < len; i++) { - cbuf[off + i] = (char) read(); - } - return len; - } - } - - /** Encode bytes into valid java identifier characters. - * Used by <a href="Utility.html#encode(byte[], boolean)">encode()</a> - */ - private static class JavaWriter extends FilterWriter { - - public JavaWriter(Writer out) { - super(out); - } - - - public void write( int b ) throws IOException { - if (isJavaIdentifierPart((char) b) && (b != ESCAPE_CHAR)) { - out.write(b); - } else { - out.write(ESCAPE_CHAR); // Escape character - // Special escape - if (b >= 0 && b < FREE_CHARS) { - out.write(CHAR_MAP[b]); - } else { // Normal escape - char[] tmp = Integer.toHexString(b).toCharArray(); - if (tmp.length == 1) { - out.write('0'); - out.write(tmp[0]); - } else { - out.write(tmp[0]); - out.write(tmp[1]); - } - } - } - } - - - public void write( char[] cbuf, int off, int len ) throws IOException { - for (int i = 0; i < len; i++) { - write(cbuf[off + i]); - } - } - - - public void write( String str, int off, int len ) throws IOException { - write(str.toCharArray(), off, len); - } - } - - /** * Escape all occurences of newline chars '\n', quotes \", etc. */ Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/BranchHandle.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/BranchHandle.java?rev=887613&r1=887612&r2=887613&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/BranchHandle.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/BranchHandle.java Sun Dec 6 00:19:52 2009 @@ -43,15 +43,7 @@ private static BranchHandle bh_list = null; // List of reusable handles - static final BranchHandle getBranchHandle( BranchInstruction i ) { - if (bh_list == null) { - return new BranchHandle(i); - } - BranchHandle bh = bh_list; - bh_list = (BranchHandle) bh.next; - bh.setInstruction(i); - return bh; - } + /** Handle adds itself to the list of resuable handles. Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/BranchInstruction.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/BranchInstruction.java?rev=887613&r1=887612&r2=887613&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/BranchInstruction.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/BranchInstruction.java Sun Dec 6 00:19:52 2009 @@ -158,12 +158,7 @@ } - /** - * @return target offset in byte code - */ - public final int getIndex() { - return index; - } + /** Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/CPInstruction.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/CPInstruction.java?rev=887613&r1=887612&r2=887613&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/CPInstruction.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/CPInstruction.java Sun Dec 6 00:19:52 2009 @@ -48,13 +48,7 @@ } - /** - * @param index to constant pool - */ - protected CPInstruction(short opcode, int index) { - super(opcode, (short) 3); - setIndex(index); - } + /** Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/ClassGen.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/ClassGen.java?rev=887613&r1=887612&r2=887613&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/ClassGen.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/ClassGen.java Sun Dec 6 00:19:52 2009 @@ -16,10 +16,6 @@ */ package org.apache.tomcat.util.bcel.generic; -import java.util.ArrayList; -import java.util.List; - -import org.apache.tomcat.util.bcel.Constants; import org.apache.tomcat.util.bcel.classfile.AccessFlags; import org.apache.tomcat.util.bcel.classfile.JavaClass; import org.apache.tomcat.util.bcel.util.BCELComparator; @@ -36,16 +32,7 @@ /* Corresponds to the fields found in a JavaClass object. */ - private String class_name, super_class_name, file_name; - private int class_name_index = -1, superclass_name_index = -1; - private int major = Constants.MAJOR_1_1, minor = Constants.MINOR_1_1; - private ConstantPoolGen cp; // Template for building up constant pool - // ArrayLists instead of arrays to gather fields, methods, etc. - private List field_vec = new ArrayList(); - private List method_vec = new ArrayList(); - private List attribute_vec = new ArrayList(); - private List interface_vec = new ArrayList(); - private List annotation_vec = new ArrayList(); + private String class_name; private static BCELComparator _cmp = new BCELComparator() { @@ -61,88 +48,13 @@ return THIS.getClassName().hashCode(); } }; - - - - - - - - public String getClassName() { return class_name; } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - private ArrayList observers; - - - - - - - - - - - public Object clone() { try { return super.clone(); @@ -152,13 +64,7 @@ } } - - - - - - /** * Return value as defined by given BCELComparator strategy. * By default two ClassGen objects are said to be equal when Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/ConstantPoolGen.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/ConstantPoolGen.java?rev=887613&r1=887612&r2=887613&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/ConstantPoolGen.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/ConstantPoolGen.java Sun Dec 6 00:19:52 2009 @@ -19,17 +19,11 @@ import java.util.HashMap; import java.util.Map; import org.apache.tomcat.util.bcel.classfile.Constant; -import org.apache.tomcat.util.bcel.classfile.ConstantClass; import org.apache.tomcat.util.bcel.classfile.ConstantDouble; -import org.apache.tomcat.util.bcel.classfile.ConstantFieldref; import org.apache.tomcat.util.bcel.classfile.ConstantFloat; import org.apache.tomcat.util.bcel.classfile.ConstantInteger; -import org.apache.tomcat.util.bcel.classfile.ConstantInterfaceMethodref; import org.apache.tomcat.util.bcel.classfile.ConstantLong; -import org.apache.tomcat.util.bcel.classfile.ConstantMethodref; -import org.apache.tomcat.util.bcel.classfile.ConstantNameAndType; import org.apache.tomcat.util.bcel.classfile.ConstantPool; -import org.apache.tomcat.util.bcel.classfile.ConstantString; import org.apache.tomcat.util.bcel.classfile.ConstantUtf8; /** @@ -51,9 +45,6 @@ protected int size; protected Constant[] constants; protected int index = 1; // First entry (0) used by JVM - private static final String METHODREF_DELIM = ":"; - private static final String IMETHODREF_DELIM = "#"; - private static final String FIELDREF_DELIM = "&"; private static final String NAT_DELIM = "%"; private static class Index implements java.io.Serializable { @@ -93,43 +84,6 @@ } } - private Map string_table = new HashMap(); - - - /** - * Look for ConstantString in ConstantPool containing String `str'. - * - * @param str String to search for - * @return index on success, -1 otherwise - */ - public int lookupString( String str ) { - Index index = (Index) string_table.get(str); - return (index != null) ? index.index : -1; - } - - - /** - * Add a new String constant to the ConstantPool, if it is not already in there. - * - * @param str String to add - * @return index of entry - */ - public int addString( String str ) { - int ret; - if ((ret = lookupString(str)) != -1) { - return ret; // Already in CP - } - int utf8 = addUtf8(str); - adjustSize(); - ConstantString s = new ConstantString(utf8); - ret = index; - constants[index++] = s; - if (!string_table.containsKey(str)) { - string_table.put(str, new Index(ret)); - } - return ret; - } - private Map class_table = new HashMap(); @@ -145,47 +99,6 @@ } - private int addClass_( String clazz ) { - int ret; - if ((ret = lookupClass(clazz)) != -1) { - return ret; // Already in CP - } - adjustSize(); - ConstantClass c = new ConstantClass(addUtf8(clazz)); - ret = index; - constants[index++] = c; - if (!class_table.containsKey(clazz)) { - class_table.put(clazz, new Index(ret)); - } - return ret; - } - - - /** - * Add a new Class reference to the ConstantPool, if it is not already in there. - * - * @param str Class to add - * @return index of entry - */ - public int addClass( String str ) { - return addClass_(str.replace('.', '/')); - } - - - /** - * Add a new Class reference to the ConstantPool for a given type. - * - * @param type Class to add - * @return index of entry - */ - public int addClass( ObjectType type ) { - return addClass(type.getClassName()); - } - - - - - /** * Look for ConstantInteger in ConstantPool. * @@ -387,175 +300,7 @@ return (_index != null) ? _index.index : -1; } - - /** - * Add a new NameAndType constant to the ConstantPool if it is not already - * in there. - * - * @param name Name string to add - * @param signature signature string to add - * @return index of entry - */ - public int addNameAndType( String name, String signature ) { - int ret; - int name_index, signature_index; - if ((ret = lookupNameAndType(name, signature)) != -1) { - return ret; // Already in CP - } - adjustSize(); - name_index = addUtf8(name); - signature_index = addUtf8(signature); - ret = index; - constants[index++] = new ConstantNameAndType(name_index, signature_index); - String key = name + NAT_DELIM + signature; - if (!n_a_t_table.containsKey(key)) { - n_a_t_table.put(key, new Index(ret)); - } - return ret; - } - - private Map cp_table = new HashMap(); - - - /** - * Look for ConstantMethodref in ConstantPool. - * - * @param class_name Where to find method - * @param method_name Guess what - * @param signature return and argument types - * @return index on success, -1 otherwise - */ - public int lookupMethodref( String class_name, String method_name, String signature ) { - Index index = (Index) cp_table.get(class_name + METHODREF_DELIM + method_name - + METHODREF_DELIM + signature); - return (index != null) ? index.index : -1; - } - - - - - - /** - * Add a new Methodref constant to the ConstantPool, if it is not already - * in there. - * - * @param class_name class name string to add - * @param method_name method name string to add - * @param signature method signature string to add - * @return index of entry - */ - public int addMethodref( String class_name, String method_name, String signature ) { - int ret, class_index, name_and_type_index; - if ((ret = lookupMethodref(class_name, method_name, signature)) != -1) { - return ret; // Already in CP - } - adjustSize(); - name_and_type_index = addNameAndType(method_name, signature); - class_index = addClass(class_name); - ret = index; - constants[index++] = new ConstantMethodref(class_index, name_and_type_index); - String key = class_name + METHODREF_DELIM + method_name + METHODREF_DELIM + signature; - if (!cp_table.containsKey(key)) { - cp_table.put(key, new Index(ret)); - } - return ret; - } - - - - - - /** - * Look for ConstantInterfaceMethodref in ConstantPool. - * - * @param class_name Where to find method - * @param method_name Guess what - * @param signature return and argument types - * @return index on success, -1 otherwise - */ - public int lookupInterfaceMethodref( String class_name, String method_name, String signature ) { - Index index = (Index) cp_table.get(class_name + IMETHODREF_DELIM + method_name - + IMETHODREF_DELIM + signature); - return (index != null) ? index.index : -1; - } - - - - - - /** - * Add a new InterfaceMethodref constant to the ConstantPool, if it is not already - * in there. - * - * @param class_name class name string to add - * @param method_name method name string to add - * @param signature signature string to add - * @return index of entry - */ - public int addInterfaceMethodref( String class_name, String method_name, String signature ) { - int ret, class_index, name_and_type_index; - if ((ret = lookupInterfaceMethodref(class_name, method_name, signature)) != -1) { - return ret; // Already in CP - } - adjustSize(); - class_index = addClass(class_name); - name_and_type_index = addNameAndType(method_name, signature); - ret = index; - constants[index++] = new ConstantInterfaceMethodref(class_index, name_and_type_index); - String key = class_name + IMETHODREF_DELIM + method_name + IMETHODREF_DELIM + signature; - if (!cp_table.containsKey(key)) { - cp_table.put(key, new Index(ret)); - } - return ret; - } - - - - - /** - * Look for ConstantFieldref in ConstantPool. - * - * @param class_name Where to find method - * @param field_name Guess what - * @param signature return and argument types - * @return index on success, -1 otherwise - */ - public int lookupFieldref( String class_name, String field_name, String signature ) { - Index index = (Index) cp_table.get(class_name + FIELDREF_DELIM + field_name - + FIELDREF_DELIM + signature); - return (index != null) ? index.index : -1; - } - - - /** - * Add a new Fieldref constant to the ConstantPool, if it is not already - * in there. - * - * @param class_name class name string to add - * @param field_name field name string to add - * @param signature signature string to add - * @return index of entry - */ - public int addFieldref( String class_name, String field_name, String signature ) { - int ret; - int class_index, name_and_type_index; - if ((ret = lookupFieldref(class_name, field_name, signature)) != -1) { - return ret; // Already in CP - } - adjustSize(); - class_index = addClass(class_name); - name_and_type_index = addNameAndType(field_name, signature); - ret = index; - constants[index++] = new ConstantFieldref(class_index, name_and_type_index); - String key = class_name + FIELDREF_DELIM + field_name + FIELDREF_DELIM + signature; - if (!cp_table.containsKey(key)) { - cp_table.put(key, new Index(ret)); - } - return ret; - } - - /** * @param i index in constant pool * @return constant pool entry at index i @@ -565,9 +310,6 @@ } - - - /** * @return intermediate constant pool */ Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/FieldGen.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/FieldGen.java?rev=887613&r1=887612&r2=887613&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/FieldGen.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/FieldGen.java Sun Dec 6 00:19:52 2009 @@ -16,7 +16,6 @@ */ package org.apache.tomcat.util.bcel.generic; -import java.util.List; import org.apache.tomcat.util.bcel.classfile.Field; import org.apache.tomcat.util.bcel.classfile.Utility; import org.apache.tomcat.util.bcel.util.BCELComparator; @@ -60,18 +59,6 @@ return type.getSignature(); } - private List observers; - - - - - - - - - - - public String getInitValue() { if (value != null) { return value.toString(); Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/FieldGenOrMethodGen.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/FieldGenOrMethodGen.java?rev=887613&r1=887612&r2=887613&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/FieldGenOrMethodGen.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/FieldGenOrMethodGen.java Sun Dec 6 00:19:52 2009 @@ -18,7 +18,6 @@ import java.util.ArrayList; import java.util.List; -import org.apache.tomcat.util.bcel.Constants; import org.apache.tomcat.util.bcel.classfile.AccessFlags; import org.apache.tomcat.util.bcel.classfile.Attribute; @@ -35,19 +34,14 @@ protected Type type; protected ConstantPoolGen cp; private List attribute_vec = new ArrayList(); - protected ArrayList annotation_vec= new ArrayList(); + protected FieldGenOrMethodGen() { } - public void setType( Type type ) { - if (type.getType() == Constants.T_ADDRESS) { - throw new IllegalArgumentException("Type can not be " + type); - } - this.type = type; - } + @@ -60,30 +54,16 @@ } - public void setName( String name ) { - this.name = name; - } + - public void setConstantPool( ConstantPoolGen cp ) { - this.cp = cp; - } + - /** - * Add an attribute to this method. Currently, the JVM knows about - * the `Code', `ConstantValue', `Synthetic' and `Exceptions' - * attributes. Other attributes will be ignored by the JVM but do no - * harm. - * - * @param a attribute to be added - */ - public void addAttribute( Attribute a ) { - attribute_vec.add(a); - } + Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/FieldOrMethod.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/FieldOrMethod.java?rev=887613&r1=887612&r2=887613&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/FieldOrMethod.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/FieldOrMethod.java Sun Dec 6 00:19:52 2009 @@ -54,26 +54,7 @@ - /** @return name of the referenced class/interface - * @deprecated If the instruction references an array class, - * this method will return "java.lang.Object". - * For code generated by Java 1.5, this answer is - * sometimes wrong (e.g., if the "clone()" method is - * called on an array). A better idea is to use - * the getReferenceType() method, which correctly distinguishes - * between class types and array types. - */ - public String getClassName( ConstantPoolGen cpg ) { - ConstantPool cp = cpg.getConstantPool(); - ConstantCP cmr = (ConstantCP) cp.getConstant(index); - String className = cp.getConstantString(cmr.getClassIndex(), - org.apache.tomcat.util.bcel.Constants.CONSTANT_Class); - if (className.startsWith("[")) { - // Turn array classes into java.lang.Object. - return "java.lang.Object"; - } - return className.replace('/', '.'); - } + 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=887613&r1=887612&r2=887613&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 Sun Dec 6 00:19:52 2009 @@ -113,327 +113,7 @@ } - /** - * Read an instruction from (byte code) input stream and return the - * appropiate object. - * - * @param bytes input stream bytes - * @return instruction object being read - */ - public static final Instruction readInstruction( ByteSequence bytes ) throws IOException { - boolean wide = false; - short opcode = (short) bytes.readUnsignedByte(); - Instruction obj = null; - if (opcode == Constants.WIDE) { // Read next opcode after wide byte - wide = true; - opcode = (short) bytes.readUnsignedByte(); - } - if (InstructionConstants.INSTRUCTIONS[opcode] != null) { - return InstructionConstants.INSTRUCTIONS[opcode]; // Used predefined immutable object, if available - } - - switch (opcode) { - 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: - obj = new ILOAD(0); - break; - case Constants.ILOAD_1: - obj = new ILOAD(1); - break; - case Constants.ILOAD_2: - obj = new ILOAD(2); - break; - case Constants.ILOAD_3: - obj = new ILOAD(3); - break; - case Constants.LLOAD_0: - obj = new LLOAD(0); - break; - case Constants.LLOAD_1: - obj = new LLOAD(1); - break; - case Constants.LLOAD_2: - obj = new LLOAD(2); - break; - case Constants.LLOAD_3: - obj = new LLOAD(3); - break; - case Constants.FLOAD_0: - obj = new FLOAD(0); - break; - case Constants.FLOAD_1: - obj = new FLOAD(1); - break; - case Constants.FLOAD_2: - obj = new FLOAD(2); - break; - case Constants.FLOAD_3: - obj = new FLOAD(3); - break; - case Constants.DLOAD_0: - obj = new DLOAD(0); - break; - case Constants.DLOAD_1: - obj = new DLOAD(1); - break; - case Constants.DLOAD_2: - obj = new DLOAD(2); - break; - case Constants.DLOAD_3: - obj = new DLOAD(3); - break; - case Constants.ALOAD_0: - obj = new ALOAD(0); - break; - case Constants.ALOAD_1: - obj = new ALOAD(1); - break; - case Constants.ALOAD_2: - obj = new ALOAD(2); - break; - case Constants.ALOAD_3: - obj = new ALOAD(3); - 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: - obj = new ISTORE(0); - break; - case Constants.ISTORE_1: - obj = new ISTORE(1); - break; - case Constants.ISTORE_2: - obj = new ISTORE(2); - break; - case Constants.ISTORE_3: - obj = new ISTORE(3); - break; - case Constants.LSTORE_0: - obj = new LSTORE(0); - break; - case Constants.LSTORE_1: - obj = new LSTORE(1); - break; - case Constants.LSTORE_2: - obj = new LSTORE(2); - break; - case Constants.LSTORE_3: - obj = new LSTORE(3); - break; - case Constants.FSTORE_0: - obj = new FSTORE(0); - break; - case Constants.FSTORE_1: - obj = new FSTORE(1); - break; - case Constants.FSTORE_2: - obj = new FSTORE(2); - break; - case Constants.FSTORE_3: - obj = new FSTORE(3); - break; - case Constants.DSTORE_0: - obj = new DSTORE(0); - break; - case Constants.DSTORE_1: - obj = new DSTORE(1); - break; - case Constants.DSTORE_2: - obj = new DSTORE(2); - break; - case Constants.DSTORE_3: - obj = new DSTORE(3); - break; - case Constants.ASTORE_0: - obj = new ASTORE(0); - break; - case Constants.ASTORE_1: - obj = new ASTORE(1); - break; - case Constants.ASTORE_2: - obj = new ASTORE(2); - break; - case Constants.ASTORE_3: - obj = new ASTORE(3); - break; - case Constants.IINC: - obj = new IINC(); - 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.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.CHECKCAST: - obj = new CHECKCAST(); - break; - case Constants.INSTANCEOF: - obj = new INSTANCEOF(); - 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; - case Constants.BREAKPOINT: - obj = new BREAKPOINT(); - break; - case Constants.IMPDEP1: - obj = new IMPDEP1(); - break; - case Constants.IMPDEP2: - obj = new IMPDEP2(); - break; - default: - throw new ClassGenException("Illegal opcode detected: " + opcode); - - } - - if (wide - && !((obj instanceof LocalVariableInstruction) || (obj instanceof IINC) || (obj instanceof RET))) { - throw new ClassGenException("Illegal opcode after wide: " + opcode); - } - obj.setOpcode(opcode); - obj.initFromFile(bytes, wide); // Do further initializations, if any - return obj; - } + /** * This method also gives right results for instructions whose @@ -475,14 +155,6 @@ } - /** - * Needed in readInstruction. - */ - private void setOpcode( short opcode ) { - this.opcode = opcode; - } - - /** Some instructions may be reused, so don't do anything by default. */ void dispose() { 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=887613&r1=887612&r2=887613&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 Sun Dec 6 00:19:52 2009 @@ -17,7 +17,6 @@ package org.apache.tomcat.util.bcel.generic; import java.util.HashSet; -import java.util.Map; import java.util.Set; import org.apache.tomcat.util.bcel.classfile.Utility; @@ -45,7 +44,6 @@ Instruction instruction; protected int i_position = -1; // byte code offset of instruction private Set targeters; - private Map attributes; public final InstructionHandle getNext() { @@ -91,18 +89,7 @@ private static InstructionHandle ih_list = null; // List of reusable handles - /** Factory method. - */ - static final InstructionHandle getInstructionHandle( Instruction i ) { - if (ih_list == null) { - return new InstructionHandle(i); - } else { - InstructionHandle ih = ih_list; - ih_list = ih.next; - ih.setInstruction(i); - return ih; - } - } + /** 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=887613&r1=887612&r2=887613&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 Sun Dec 6 00:19:52 2009 @@ -17,8 +17,6 @@ package org.apache.tomcat.util.bcel.generic; import java.io.Serializable; -import java.util.List; -import org.apache.tomcat.util.bcel.Constants; /** * This class is a container for a list of <a @@ -42,9 +40,6 @@ public class InstructionList implements Serializable { private InstructionHandle start = null, end = null; - private int length = 0; // number of elements in list - private int[] byte_positions; // byte code offsets corresponding to instructions - /** * Create (empty) instruction list. @@ -52,195 +47,7 @@ public InstructionList() { } - - - - - - - - - - - /** - * Test for empty list. - */ - public boolean isEmpty() { - return start == null; - } // && end == null - - - /** - * Find the target instruction (handle) that corresponds to the given target - * position (byte code offset). - * - * @param ihs array of instruction handles, i.e. il.getInstructionHandles() - * @param pos array of positions corresponding to ihs, i.e. il.getInstructionPositions() - * @param count length of arrays - * @param target target position to search for - * @return target position's instruction handle if available - */ - public static InstructionHandle findHandle( InstructionHandle[] ihs, int[] pos, int count, - int target ) { - int l = 0, r = count - 1; - /* Do a binary search since the pos array is orderd. - */ - do { - int i = (l + r) / 2; - int j = pos[i]; - if (j == target) { - return ihs[i]; - } else if (target < j) { - r = i - 1; - } else { - l = i + 1; - } - } while (l <= r); - return null; - } - - - - - - - - - /** - * Append another list after 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 append to this one - * @return instruction handle pointing to the <B>first</B> appended instruction - */ - public InstructionHandle append( InstructionHandle ih, InstructionList il ) { - if (il == null) { - throw new ClassGenException("Appending null InstructionList"); - } - if (il.isEmpty()) { - return ih; - } - InstructionHandle next = ih.next, ret = il.start; - ih.next = il.start; - il.start.prev = ih; - il.end.next = next; - if (next != null) { - next.prev = il.end; - } else { - end = il.end; // Update end ... - } - length += il.length; // Update length - il.clear(); - return ret; - } - - - - - - - - /** - * Append an instruction to the end of this list. - * - * @param ih instruction to append - */ - private void append( InstructionHandle ih ) { - if (isEmpty()) { - start = end = ih; - ih.next = ih.prev = null; - } else { - end.next = ih; - ih.prev = end; - ih.next = null; - end = ih; - } - length++; // Update length - } - - - /** - * Append an instruction to the end of this list. - * - * @param i instruction to append - * @return instruction handle of the appended instruction - */ - public InstructionHandle append( Instruction i ) { - InstructionHandle ih = InstructionHandle.getInstructionHandle(i); - append(ih); - return ih; - } - - - /** - * Append a branch instruction to the end of this list. - * - * @param i branch instruction to append - * @return branch instruction handle of the appended instruction - */ - public BranchHandle append( BranchInstruction i ) { - BranchHandle ih = BranchHandle.getBranchHandle(i); - append(ih); - return ih; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -265,102 +72,6 @@ } - public void setPositions() { - setPositions(false); - } - - - /** - * Give all instructions their position number (offset in byte stream), i.e., - * make the list ready to be dumped. - * - * @param check Perform sanity checks, e.g. if all targeted instructions really belong - * to this list - */ - public void setPositions( boolean check ) { - int max_additional_bytes = 0, additional_bytes = 0; - int index = 0, count = 0; - int[] pos = new int[length]; - /* Pass 0: Sanity checks - */ - if (check) { - for (InstructionHandle ih = start; ih != null; ih = ih.next) { - Instruction i = ih.instruction; - if (i instanceof BranchInstruction) { // target instruction within list? - Instruction inst = ((BranchInstruction) i).getTarget().instruction; - if (!contains(inst)) { - throw new ClassGenException("Branch target of " - + Constants.OPCODE_NAMES[i.opcode] + ":" + inst - + " not in instruction list"); - } - if (i instanceof Select) { - InstructionHandle[] targets = ((Select) i).getTargets(); - for (int j = 0; j < targets.length; j++) { - inst = targets[j].instruction; - if (!contains(inst)) { - throw new ClassGenException("Branch target of " - + Constants.OPCODE_NAMES[i.opcode] + ":" + inst - + " not in instruction list"); - } - } - } - if (!(ih instanceof BranchHandle)) { - throw new ClassGenException("Branch instruction " - + Constants.OPCODE_NAMES[i.opcode] + ":" + inst - + " not contained in BranchHandle."); - } - } - } - } - /* Pass 1: Set position numbers and sum up the maximum number of bytes an - * instruction may be shifted. - */ - for (InstructionHandle ih = start; ih != null; ih = ih.next) { - Instruction i = ih.instruction; - ih.setPosition(index); - pos[count++] = index; - /* Get an estimate about how many additional bytes may be added, because - * BranchInstructions may have variable length depending on the target - * offset (short vs. int) or alignment issues (TABLESWITCH and - * LOOKUPSWITCH). - */ - switch (i.getOpcode()) { - case Constants.JSR: - case Constants.GOTO: - max_additional_bytes += 2; - break; - case Constants.TABLESWITCH: - case Constants.LOOKUPSWITCH: - max_additional_bytes += 3; - break; - } - index += i.getLength(); - } - /* Pass 2: Expand the variable-length (Branch)Instructions depending on - * the target offset (short or int) and ensure that branch targets are - * within this list. - */ - for (InstructionHandle ih = start; ih != null; ih = ih.next) { - additional_bytes += ih.updatePosition(additional_bytes, max_additional_bytes); - } - /* Pass 3: Update position numbers (which may have changed due to the - * preceding expansions), like pass 1. - */ - index = count = 0; - for (InstructionHandle ih = start; ih != null; ih = ih.next) { - Instruction i = ih.instruction; - ih.setPosition(index); - pos[count++] = index; - index += i.getLength(); - } - byte_positions = new int[count]; // Trim to proper size - System.arraycopy(pos, 0, byte_positions, 0, count); - } - - - - - @@ -382,30 +93,6 @@ } - - - - - - - - - - - - - - - - private void clear() { - start = end = null; - length = 0; - } - - - - - /** * @return start of list */ @@ -420,30 +107,4 @@ public InstructionHandle getEnd() { return end; } - - - - - - - - - - - - - - - - - private List observers; - - - - - - - - - } 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=887613&r1=887612&r2=887613&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 Sun Dec 6 00:19:52 2009 @@ -36,42 +36,8 @@ } - /** @return return address type - */ - public Type getType( ConstantPoolGen cp ) { - return new ReturnaddressType(physicalSuccessor()); - } + - /** - * Returns an InstructionHandle to the physical successor - * of this JsrInstruction. <B>For this method to work, - * this JsrInstruction object must not be shared between - * multiple InstructionHandle objects!</B> - * Formally, there must not be InstructionHandle objects - * i, j where i != j and i.getInstruction() == this == - * j.getInstruction(). - * @return an InstructionHandle to the "next" instruction that - * will be executed when RETurned from a subroutine. - */ - public InstructionHandle physicalSuccessor() { - InstructionHandle ih = this.target; - // Rewind! - while (ih.getPrev() != null) { - ih = ih.getPrev(); - } - // Find the handle for "this" JsrInstruction object. - while (ih.getInstruction() != this) { - ih = ih.getNext(); - } - InstructionHandle toThis = ih; - while (ih != null) { - ih = ih.getNext(); - if ((ih != null) && (ih.getInstruction() == this)) { - throw new RuntimeException("physicalSuccessor() called on a shared JsrInstruction."); - } - } - // Return the physical successor - return toThis.getNext(); - } + } 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=887613&r1=887612&r2=887613&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 Sun Dec 6 00:19:52 2009 @@ -76,9 +76,7 @@ } - public void setName( String name ) { - this.name = name; - } + public String getName() { @@ -86,9 +84,7 @@ } - public void setType( Type type ) { - this.type = type; - } + Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/MethodGen.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/MethodGen.java?rev=887613&r1=887612&r2=887613&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/MethodGen.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/MethodGen.java Sun Dec 6 00:19:52 2009 @@ -46,22 +46,10 @@ */ public class MethodGen extends FieldGenOrMethodGen { - private String class_name; private Type[] arg_types; - private String[] arg_names; - private int max_locals; - private int max_stack; private InstructionList il; - private boolean strip_attributes; private List variable_vec = new ArrayList(); - private List line_number_vec = new ArrayList(); - private List exception_vec = new ArrayList(); private List throws_vec = new ArrayList(); - private List code_attrs_vec = new ArrayList(); - - private List[] param_annotations; // Array of lists containing AnnotationGen objects - private boolean hasParameterAnnotations = false; - private boolean haveUnpackedParameterAnnotations = false; private static BCELComparator _cmp = new BCELComparator() { @@ -80,24 +68,6 @@ }; - - - - - - - - - - - - - - - - - - /** * Sort local variables by index */ @@ -169,153 +139,11 @@ } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public String getSignature() { return Type.getMethodSignature(type, arg_types); } - - - - - - - - - - - - - - - - private List observers; - - - - - - - - - - - /** * Return string representation close to declaration format, * `public static void main(String[]) throws IOException', e.g. Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/NamedAndTyped.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/NamedAndTyped.java?rev=887613&r1=887612&r2=887613&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/NamedAndTyped.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/NamedAndTyped.java Sun Dec 6 00:19:52 2009 @@ -31,8 +31,8 @@ - public void setName( String name ); + - public void setType( Type type ); + } Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/ObjectType.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/ObjectType.java?rev=887613&r1=887612&r2=887613&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/ObjectType.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/ObjectType.java Sun Dec 6 00:19:52 2009 @@ -38,11 +38,7 @@ } - /** @return name of referenced class - */ - public String getClassName() { - return class_name; - } + /** @return a hash code value for the object. Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/Select.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/Select.java?rev=887613&r1=887612&r2=887613&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/Select.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/Select.java Sun Dec 6 00:19:52 2009 @@ -195,12 +195,7 @@ - /** - * @return array of match target offsets - */ - public int[] getIndices() { - return indices; - } + /** Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/Type.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/Type.java?rev=887613&r1=887612&r2=887613&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/Type.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/bcel/generic/Type.java Sun Dec 6 00:19:52 2009 @@ -235,7 +235,6 @@ static int getArgumentTypesSize( String signature ) { int res = 0; int index; - Type[] types; try { // Read all declarations between for `(' and `)' if (signature.charAt(0) != '(') { throw new ClassFormatException("Invalid method signature: " + signature); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
