Author: markt Date: Fri Sep 12 12:35:49 2014 New Revision: 1624521 URL: http://svn.apache.org/r1624521 Log: Port simplications from trunk
Modified: tomcat/tc7.0.x/trunk/ (props changed) tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/ (props changed) tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapEntry.java tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTable.java tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTableEntry.java tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapType.java Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ Merged /tomcat/trunk:r1539887,1540383-1540386 Propchange: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/ ------------------------------------------------------------------------------ Merged /tomcat/trunk/java/org/apache/tomcat/util/bcel:r1539887,1540383-1540386 Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java?rev=1624521&r1=1624520&r2=1624521&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java Fri Sep 12 12:35:49 2014 @@ -43,6 +43,8 @@ import org.apache.tomcat.util.bcel.Const */ public final class ClassParser { + private static final int MAGIC = 0xCAFEBABE; + private DataInputStream file; private boolean fileOwned; private String file_name; @@ -231,8 +233,7 @@ public final class ClassParser { * @throws ClassFormatException */ private void readID() throws IOException, ClassFormatException { - int magic = 0xCAFEBABE; - if (file.readInt() != magic) { + if (file.readInt() != MAGIC) { throw new ClassFormatException(file_name + " is not a Java .class file"); } } Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapEntry.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapEntry.java?rev=1624521&r1=1624520&r2=1624521&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapEntry.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapEntry.java Fri Sep 12 12:35:49 2014 @@ -34,12 +34,6 @@ public final class StackMapEntry impleme private static final long serialVersionUID = 1L; - private int number_of_locals; - private StackMapType[] types_of_locals; - private int number_of_stack_items; - private StackMapType[] types_of_stack_items; - - /** * Construct object from file stream. * @param file Input stream @@ -47,14 +41,14 @@ public final class StackMapEntry impleme */ StackMapEntry(DataInputStream file) throws IOException { file.readShort(); // Unused byte_code_offset - number_of_locals = file.readShort(); - types_of_locals = null; - types_of_stack_items = null; + int number_of_locals = file.readShort(); + StackMapType[] types_of_locals = null; + StackMapType[] types_of_stack_items = null; types_of_locals = new StackMapType[number_of_locals]; for (int i = 0; i < number_of_locals; i++) { types_of_locals[i] = new StackMapType(file); } - number_of_stack_items = file.readShort(); + int number_of_stack_items = file.readShort(); types_of_stack_items = new StackMapType[number_of_stack_items]; for (int i = 0; i < number_of_stack_items; i++) { types_of_stack_items[i] = new StackMapType(file); Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTable.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTable.java?rev=1624521&r1=1624520&r2=1624521&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTable.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTable.java Fri Sep 12 12:35:49 2014 @@ -37,20 +37,8 @@ import java.io.IOException; public final class StackMapTable extends Attribute { private static final long serialVersionUID = -2931695092763099621L; - private int map_length; - private StackMapTableEntry[] map; // Table of stack map entries - - - /* - * @param name_index Index of name - * @param length Content length in bytes - * @param map Table of stack map entries - * @param constant_pool Array of constants - */ - public StackMapTable(int name_index, int length, StackMapTableEntry[] map, ConstantPool constant_pool) { - super(name_index, length, constant_pool); - setStackMapTable(map); - } + private final int map_length; + private final StackMapTableEntry[] map; // Table of stack map entries /** @@ -63,20 +51,11 @@ public final class StackMapTable extends */ StackMapTable(int name_index, int length, DataInputStream file, ConstantPool constant_pool) throws IOException { - this(name_index, length, (StackMapTableEntry[]) null, constant_pool); + super(name_index, length, constant_pool); map_length = file.readUnsignedShort(); map = new StackMapTableEntry[map_length]; for (int i = 0; i < map_length; i++) { map[i] = new StackMapTableEntry(file); } } - - - /** - * @param map Array of stack map entries - */ - public final void setStackMapTable( StackMapTableEntry[] map ) { - this.map = map; - map_length = (map == null) ? 0 : map.length; - } } Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTableEntry.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTableEntry.java?rev=1624521&r1=1624520&r2=1624521&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTableEntry.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapTableEntry.java Fri Sep 12 12:35:49 2014 @@ -49,7 +49,11 @@ public final class StackMapTableEntry im * @throws IOException */ StackMapTableEntry(DataInputStream file) throws IOException { - this(file.read(), -1, null, -1, null); + this.frame_type = file.read(); + this.number_of_locals = -1; + this.types_of_locals = null; + this.number_of_stack_items = -1; + this.types_of_stack_items = null; if (frame_type >= Constants.SAME_FRAME && frame_type <= Constants.SAME_FRAME_MAX) { // NO-OP @@ -90,15 +94,4 @@ public final class StackMapTableEntry im throw new ClassFormatException ("Invalid frame type found while parsing stack map table: " + frame_type); } } - - - public StackMapTableEntry(int tag, int number_of_locals, - StackMapType[] types_of_locals, int number_of_stack_items, - StackMapType[] types_of_stack_items) { - this.frame_type = tag; - this.number_of_locals = number_of_locals; - this.types_of_locals = types_of_locals; - this.number_of_stack_items = number_of_stack_items; - this.types_of_stack_items = types_of_stack_items; - } } Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapType.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapType.java?rev=1624521&r1=1624520&r2=1624521&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapType.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/StackMapType.java Fri Sep 12 12:35:49 2014 @@ -36,33 +36,19 @@ public final class StackMapType implemen private static final long serialVersionUID = 1L; - private byte type; - - /** * Construct object from file stream. * @param file Input stream * @throws IOException */ StackMapType(DataInput file) throws IOException { - setType(file.readByte()); - if (hasIndex()) { - file.readShort(); // Unused index + byte type = file.readByte(); + if ((type < Constants.ITEM_Bogus) || (type > Constants.ITEM_NewObject)) { + throw new RuntimeException("Illegal type for StackMapType: " + type); } - } - - - public void setType( byte t ) { - if ((t < Constants.ITEM_Bogus) || (t > Constants.ITEM_NewObject)) { - throw new RuntimeException("Illegal type for StackMapType: " + t); + // Check to see if type has an index + if ((type == Constants.ITEM_Object) || (type == Constants.ITEM_NewObject)) { + file.readShort(); // Unused index } - type = t; - } - - - /** @return true, if type is either ITEM_Object or ITEM_NewObject - */ - public final boolean hasIndex() { - return ((type == Constants.ITEM_Object) || (type == Constants.ITEM_NewObject)); } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org