Author: markt Date: Wed Sep 17 12:42:29 2014 New Revision: 1625558 URL: http://svn.apache.org/r1625558 Log: Use the DataInput interface rather than an implementation. Port of r1625501 from trunk
Also Align 7.0.x with trunk after comparing the two 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/AnnotationEntry.java tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Annotations.java 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/Constant.java tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantPool.java tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantUtf8.java tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ElementValue.java tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ElementValuePair.java Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ Merged /tomcat/trunk:r1625501 Propchange: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/ ------------------------------------------------------------------------------ Merged /tomcat/trunk/java/org/apache/tomcat/util/bcel:r1625501 Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/AnnotationEntry.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/AnnotationEntry.java?rev=1625558&r1=1625557&r2=1625558&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/AnnotationEntry.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/AnnotationEntry.java Wed Sep 17 12:42:29 2014 @@ -17,7 +17,7 @@ */ package org.apache.tomcat.util.bcel.classfile; -import java.io.DataInputStream; +import java.io.DataInput; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -35,32 +35,26 @@ public class AnnotationEntry implements private final int type_index; private final ConstantPool constant_pool; - // FIXME: add 'final' - private List<ElementValuePair> element_value_pairs; + private final List<ElementValuePair> element_value_pairs; /** - * Factory method to create an AnnotionEntry from a DataInputStream + * Creates an AnnotationEntry from a DataInputStream * * @param file * @param constant_pool - * @return the entry * @throws IOException */ - public static AnnotationEntry read(DataInputStream file, ConstantPool constant_pool) throws IOException { - - final AnnotationEntry annotationEntry = new AnnotationEntry(file.readUnsignedShort(), constant_pool); - final int num_element_value_pairs = (file.readUnsignedShort()); - annotationEntry.element_value_pairs = new ArrayList<ElementValuePair>(); - for (int i = 0; i < num_element_value_pairs; i++) { - annotationEntry.element_value_pairs.add(new ElementValuePair(file.readUnsignedShort(), ElementValue.readElementValue(file, constant_pool), - constant_pool)); - } - return annotationEntry; - } + AnnotationEntry(DataInput file, ConstantPool constant_pool) throws IOException { - AnnotationEntry(int type_index, ConstantPool constant_pool) { - this.type_index = type_index; this.constant_pool = constant_pool; + + type_index = file.readUnsignedShort(); + int num_element_value_pairs = file.readUnsignedShort(); + + element_value_pairs = new ArrayList<ElementValuePair>(num_element_value_pairs); + for (int i = 0; i < num_element_value_pairs; i++) { + element_value_pairs.add(new ElementValuePair(file, constant_pool)); + } } /** Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Annotations.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Annotations.java?rev=1625558&r1=1625557&r2=1625558&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Annotations.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Annotations.java Wed Sep 17 12:42:29 2014 @@ -17,7 +17,7 @@ */ package org.apache.tomcat.util.bcel.classfile; -import java.io.DataInputStream; +import java.io.DataInput; import java.io.IOException; /** @@ -34,12 +34,12 @@ public class Annotations { * @param file Input stream * @param constant_pool Array of constants */ - Annotations(DataInputStream file, ConstantPool constant_pool) + Annotations(DataInput file, ConstantPool constant_pool) throws IOException { final int annotation_table_length = (file.readUnsignedShort()); annotation_table = new AnnotationEntry[annotation_table_length]; for (int i = 0; i < annotation_table_length; i++) { - annotation_table[i] = AnnotationEntry.read(file, constant_pool); + annotation_table[i] = new AnnotationEntry(file, constant_pool); } } 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=1625558&r1=1625557&r2=1625558&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 Wed Sep 17 12:42:29 2014 @@ -18,6 +18,7 @@ package org.apache.tomcat.util.bcel.classfile; import java.io.BufferedInputStream; +import java.io.DataInput; import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; @@ -42,7 +43,7 @@ public final class ClassParser { private static final int MAGIC = 0xCAFEBABE; - private final DataInputStream file; + private final DataInput file; private String class_name, superclass_name; private int access_flags; // Access rights of parsed class private String[] interface_names; // Names of implemented interfaces Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Constant.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Constant.java?rev=1625558&r1=1625557&r2=1625558&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Constant.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/Constant.java Wed Sep 17 12:42:29 2014 @@ -17,7 +17,7 @@ */ package org.apache.tomcat.util.bcel.classfile; -import java.io.DataInputStream; +import java.io.DataInput; import java.io.IOException; import org.apache.tomcat.util.bcel.Constants; @@ -62,7 +62,7 @@ public abstract class Constant { * @param file Input stream * @return Constant object */ - static Constant readConstant( DataInputStream file ) throws IOException, + static Constant readConstant(DataInput file ) throws IOException, ClassFormatException { byte b = file.readByte(); // Read tag byte int skipSize; Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantPool.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantPool.java?rev=1625558&r1=1625557&r2=1625558&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantPool.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantPool.java Wed Sep 17 12:42:29 2014 @@ -17,7 +17,7 @@ */ package org.apache.tomcat.util.bcel.classfile; -import java.io.DataInputStream; +import java.io.DataInput; import java.io.IOException; import org.apache.tomcat.util.bcel.Constants; @@ -45,7 +45,7 @@ public class ConstantPool { * @throws IOException * @throws ClassFormatException */ - ConstantPool(DataInputStream file) throws IOException, ClassFormatException { + ConstantPool(DataInput file) throws IOException, ClassFormatException { int constant_pool_count = file.readUnsignedShort(); constant_pool = new Constant[constant_pool_count]; /* constant_pool[0] is unused by the compiler and may be used freely Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantUtf8.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantUtf8.java?rev=1625558&r1=1625557&r2=1625558&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantUtf8.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantUtf8.java Wed Sep 17 12:42:29 2014 @@ -16,7 +16,7 @@ */ package org.apache.tomcat.util.bcel.classfile; -import java.io.DataInputStream; +import java.io.DataInput; import java.io.IOException; import org.apache.tomcat.util.bcel.Constants; @@ -34,7 +34,7 @@ public final class ConstantUtf8 extends private final String bytes; - static ConstantUtf8 getInstance(DataInputStream file) throws IOException { + static ConstantUtf8 getInstance(DataInput file) throws IOException { return new ConstantUtf8(file.readUTF()); } Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ElementValue.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ElementValue.java?rev=1625558&r1=1625557&r2=1625558&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ElementValue.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ElementValue.java Wed Sep 17 12:42:29 2014 @@ -17,7 +17,7 @@ */ package org.apache.tomcat.util.bcel.classfile; -import java.io.DataInputStream; +import java.io.DataInput; import java.io.IOException; /** @@ -64,7 +64,7 @@ public abstract class ElementValue public static final int PRIMITIVE_BOOLEAN = 'Z'; - public static ElementValue readElementValue(DataInputStream dis, + public static ElementValue readElementValue(DataInput dis, ConstantPool cpool) throws IOException { byte type = dis.readByte(); @@ -105,7 +105,7 @@ public abstract class ElementValue return new ClassElementValue(CLASS, dis.readUnsignedShort(), cpool); case '@': // Annotation // TODO isRuntimeVisible - return new AnnotationElementValue(ANNOTATION, AnnotationEntry.read( + return new AnnotationElementValue(ANNOTATION, new AnnotationEntry( dis, cpool), cpool); case '[': // Array int numArrayVals = dis.readUnsignedShort(); Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ElementValuePair.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ElementValuePair.java?rev=1625558&r1=1625557&r2=1625558&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ElementValuePair.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ElementValuePair.java Wed Sep 17 12:42:29 2014 @@ -17,6 +17,9 @@ */ package org.apache.tomcat.util.bcel.classfile; +import java.io.DataInput; +import java.io.IOException; + import org.apache.tomcat.util.bcel.Constants; /** @@ -33,11 +36,10 @@ public class ElementValuePair private final int elementNameIndex; - ElementValuePair(int elementNameIndex, ElementValue elementValue, - ConstantPool constantPool) { - this.elementValue = elementValue; - this.elementNameIndex = elementNameIndex; + ElementValuePair(DataInput file, ConstantPool constantPool) throws IOException { this.constantPool = constantPool; + this.elementNameIndex = file.readUnsignedShort(); + this.elementValue = ElementValue.readElementValue(file, constantPool); } public String getNameString() --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org