ASF Bugzilla – Attachment 31993 Details for
Bug 56953
A improvement for "DataInputStream"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
patch (text/plain), 85.98 KB, created by
hzhang9
on 2014-09-11 05:51:38 UTC
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
hzhang9
Created:
2014-09-11 05:51:38 UTC
Size:
85.98 KB
patch
obsolete
>diff --git a/Constants.java b/Constants.java >index def846f..c3a6d0f 100644 >--- a/Constants.java >+++ b/Constants.java >@@ -20,6 +20,7 @@ package org.apache.tomcat.util.bcel; > /** > * Constants for the project, mostly defined in the JVM specification. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > */ > public interface Constants { >@@ -511,17 +512,15 @@ public interface Constants { > public static final byte ATTR_SIGNATURE = 10; > public static final byte ATTR_STACK_MAP = 11; > public static final byte ATTR_RUNTIME_VISIBLE_ANNOTATIONS = 12; >- public static final byte ATTR_RUNTIME_INVISIBLE_ANNOTATIONS = 13; >+ public static final byte ATTR_RUNTIMEIN_VISIBLE_ANNOTATIONS = 13; > public static final byte ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS = 14; >- public static final byte ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS = 15; >+ public static final byte ATTR_RUNTIMEIN_VISIBLE_PARAMETER_ANNOTATIONS = 15; > public static final byte ATTR_ANNOTATION_DEFAULT = 16; > public static final byte ATTR_LOCAL_VARIABLE_TYPE_TABLE = 17; > public static final byte ATTR_ENCLOSING_METHOD = 18; > public static final byte ATTR_STACK_MAP_TABLE = 19; >- public static final byte ATTR_BOOTSTRAP_METHODS = 20; >- public static final byte ATTR_METHOD_PARAMETERS = 21; > >- public static final short KNOWN_ATTRIBUTES = 22; >+ public static final short KNOWN_ATTRIBUTES = 20; > > // TOFO: FIXXXXX > public static final String[] ATTRIBUTE_NAMES = { >@@ -531,8 +530,7 @@ public interface Constants { > "PMGClass", "Signature", "StackMap", > "RuntimeVisibleAnnotations", "RuntimeInvisibleAnnotations", > "RuntimeVisibleParameterAnnotations", "RuntimeInvisibleParameterAnnotations", >- "AnnotationDefault", "LocalVariableTypeTable", "EnclosingMethod", "StackMapTable", >- "BootstrapMethods", "MethodParameters" >+ "AnnotationDefault", "LocalVariableTypeTable", "EnclosingMethod", "StackMapTable" > }; > > /** Constants used in the StackMap attribute. >diff --git a/classfile/AccessFlags.java b/classfile/AccessFlags.java >index 23839ec..dcc78bc 100644 >--- a/classfile/AccessFlags.java >+++ b/classfile/AccessFlags.java >@@ -21,6 +21,7 @@ package org.apache.tomcat.util.bcel.classfile; > * Super class for all objects that have modifiers like private, final, ... > * I.e. classes, fields, and methods. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > */ > public abstract class AccessFlags implements java.io.Serializable { >diff --git a/classfile/AnnotationDefault.java b/classfile/AnnotationDefault.java >index e1a2789..5125de8 100644 >--- a/classfile/AnnotationDefault.java >+++ b/classfile/AnnotationDefault.java >@@ -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; >@@ -25,8 +25,9 @@ import org.apache.tomcat.util.bcel.Constants; > /** > * represents the default value of a annotation for a method info > * >+ * @version $Id: AnnotationDefault 1 2005-02-13 03:15:08Z dbrosius $ > * @author <A HREF="mailto:dbrosius@qis.net">D. Brosius</A> >- * @since 6.0 >+ * @since 5.3 > */ > public class AnnotationDefault extends Attribute > { >@@ -44,7 +45,7 @@ public class AnnotationDefault extends Attribute > * Array of constants > */ > public AnnotationDefault(int name_index, int length, >- DataInputStream file, ConstantPool constant_pool) >+ DataInput file, ConstantPool constant_pool) > throws IOException > { > this(name_index, length, (ElementValue) null, >@@ -52,6 +53,7 @@ public class AnnotationDefault extends Attribute > default_value = ElementValue.readElementValue(file, constant_pool); > } > >+ > /** > * @param name_index > * Index pointing to the name <em>Code</em> >diff --git a/classfile/AnnotationElementValue.java b/classfile/AnnotationElementValue.java >index 61cb80b..231dc20 100644 >--- a/classfile/AnnotationElementValue.java >+++ b/classfile/AnnotationElementValue.java >@@ -17,7 +17,7 @@ > */ > package org.apache.tomcat.util.bcel.classfile; > >-import java.io.DataOutputStream; >+import java.io.DataOutput; > import java.io.IOException; > > public class AnnotationElementValue extends ElementValue >@@ -29,15 +29,14 @@ public class AnnotationElementValue extends ElementValue > ConstantPool cpool) > { > super(type, cpool); >- if (type != ANNOTATION) { >+ if (type != ANNOTATION) > throw new RuntimeException( > "Only element values of type annotation can be built with this ctor - type specified: " + type); >- } > this.annotationEntry = annotationEntry; > } > > @Override >- public void dump(DataOutputStream dos) throws IOException >+ public void dump(DataOutput dos) throws IOException > { > dos.writeByte(type); // u1 type of value (ANNOTATION == '@') > annotationEntry.dump(dos); >diff --git a/classfile/AnnotationEntry.java b/classfile/AnnotationEntry.java >index 15190bc..e36a092 100644 >--- a/classfile/AnnotationEntry.java >+++ b/classfile/AnnotationEntry.java >@@ -17,10 +17,7 @@ > */ > package org.apache.tomcat.util.bcel.classfile; > >-import java.io.DataInputStream; >-import java.io.DataOutputStream; >-import java.io.IOException; >-import java.io.Serializable; >+import java.io.*; > import java.util.ArrayList; > import java.util.List; > >@@ -29,8 +26,9 @@ import org.apache.tomcat.util.bcel.Constants; > /** > * represents one annotation in the annotation table > * >+ * @version $Id: AnnotationEntry > * @author <A HREF="mailto:dbrosius@mebigfatguy.com">D. Brosius</A> >- * @since 6.0 >+ * @since 5.3 > */ > public class AnnotationEntry implements Constants, Serializable { > >@@ -42,14 +40,14 @@ public class AnnotationEntry implements Constants, Serializable { > private List<ElementValuePair> element_value_pairs; > > /** >- * Factory method to create an AnnotionEntry from a DataInputStream >+ * Factory method to create an AnnotionEntry from a DataInput > * > * @param file > * @param constant_pool > * @return the entry > * @throws IOException > */ >- public static AnnotationEntry read(DataInputStream file, ConstantPool constant_pool) throws IOException { >+ public static AnnotationEntry read(DataInput file, ConstantPool constant_pool) throws IOException { > > final AnnotationEntry annotationEntry = new AnnotationEntry(file.readUnsignedShort(), constant_pool); > final int num_element_value_pairs = (file.readUnsignedShort()); >@@ -82,7 +80,7 @@ public class AnnotationEntry implements Constants, Serializable { > return element_value_pairs.toArray(new ElementValuePair[element_value_pairs.size()]); > } > >- public void dump(DataOutputStream dos) throws IOException { >+ public void dump(DataOutput dos) throws IOException { > dos.writeShort(type_index); // u2 index of type name in cpool > dos.writeShort(element_value_pairs.size()); // u2 element_value pair > // count >diff --git a/classfile/Annotations.java b/classfile/Annotations.java >index c8601d3..0f80d17 100644 >--- a/classfile/Annotations.java >+++ b/classfile/Annotations.java >@@ -17,15 +17,16 @@ > */ > package org.apache.tomcat.util.bcel.classfile; > >-import java.io.DataInputStream; >-import java.io.DataOutputStream; >+import java.io.DataInput; >+import java.io.DataOutput; > import java.io.IOException; > > /** > * base class for annotations > * >+ * @version $Id: Annotations > * @author <A HREF="mailto:dbrosius@qis.net">D. Brosius</A> >- * @since 6.0 >+ * @since 5.3 > */ > public abstract class Annotations extends Attribute { > >@@ -40,7 +41,7 @@ public abstract class Annotations extends Attribute { > * @param file Input stream > * @param constant_pool Array of constants > */ >- public Annotations(byte annotation_type, int name_index, int length, DataInputStream file, ConstantPool constant_pool) throws IOException { >+ public Annotations(byte annotation_type, int name_index, int length, DataInput file, ConstantPool constant_pool) throws IOException { > this(annotation_type, name_index, length, (AnnotationEntry[]) null, constant_pool); > final int annotation_table_length = (file.readUnsignedShort()); > annotation_table = new AnnotationEntry[annotation_table_length]; >@@ -76,7 +77,7 @@ public abstract class Annotations extends Attribute { > return annotation_table; > } > >- protected void writeAnnotations(DataOutputStream dos) throws IOException { >+ protected void writeAnnotations(DataOutput dos) throws IOException { > if (annotation_table == null) { > return; > } >diff --git a/classfile/ArrayElementValue.java b/classfile/ArrayElementValue.java >index 40532b7..bead9ad 100644 >--- a/classfile/ArrayElementValue.java >+++ b/classfile/ArrayElementValue.java >@@ -17,7 +17,7 @@ > */ > package org.apache.tomcat.util.bcel.classfile; > >-import java.io.DataOutputStream; >+import java.io.DataOutput; > import java.io.IOException; > > public class ArrayElementValue extends ElementValue >@@ -43,15 +43,14 @@ public class ArrayElementValue extends ElementValue > public ArrayElementValue(int type, ElementValue[] datums, ConstantPool cpool) > { > super(type, cpool); >- if (type != ARRAY) { >+ if (type != ARRAY) > throw new RuntimeException( > "Only element values of type array can be built with this ctor - type specified: " + type); >- } > this.evalues = datums; > } > > @Override >- public void dump(DataOutputStream dos) throws IOException >+ public void dump(DataOutput dos) throws IOException > { > dos.writeByte(type); // u1 type of value (ARRAY == '[') > dos.writeShort(evalues.length); >@@ -69,9 +68,8 @@ public class ArrayElementValue extends ElementValue > for (int i = 0; i < evalues.length; i++) > { > sb.append(evalues[i].stringifyValue()); >- if ((i + 1) < evalues.length) { >+ if ((i + 1) < evalues.length) > sb.append(","); >- } > } > sb.append("]"); > return sb.toString(); >diff --git a/classfile/Attribute.java b/classfile/Attribute.java >index 12c939c..3c0beec 100644 >--- a/classfile/Attribute.java >+++ b/classfile/Attribute.java >@@ -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.io.Serializable; > import java.util.HashMap; >@@ -33,6 +33,7 @@ import org.apache.tomcat.util.bcel.Constants; > * <em>Synthetic</em> attributes are supported. The <em>Unknown</em> > * attribute stands for non-standard-attributes. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see ConstantValue > * @see SourceFile >@@ -80,7 +81,7 @@ public abstract class Attribute implements Cloneable, Serializable > * constants @return Attribute @throws IOException @throws > * ClassFormatException > */ >- public static final Attribute readAttribute(DataInputStream file, >+ public static final Attribute readAttribute(DataInput file, > ConstantPool constant_pool) throws IOException, > ClassFormatException > { >@@ -145,13 +146,13 @@ public abstract class Attribute implements Cloneable, Serializable > case Constants.ATTR_RUNTIME_VISIBLE_ANNOTATIONS: > return new RuntimeVisibleAnnotations(name_index, length, file, > constant_pool); >- case Constants.ATTR_RUNTIME_INVISIBLE_ANNOTATIONS: >+ case Constants.ATTR_RUNTIMEIN_VISIBLE_ANNOTATIONS: > return new RuntimeInvisibleAnnotations(name_index, length, file, > constant_pool); > case Constants.ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS: > return new RuntimeVisibleParameterAnnotations(name_index, length, > file, constant_pool); >- case Constants.ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS: >+ case Constants.ATTR_RUNTIMEIN_VISIBLE_PARAMETER_ANNOTATIONS: > return new RuntimeInvisibleParameterAnnotations(name_index, length, > file, constant_pool); > case Constants.ATTR_ANNOTATION_DEFAULT: >@@ -164,12 +165,6 @@ public abstract class Attribute implements Cloneable, Serializable > return new EnclosingMethod(name_index, length, file, constant_pool); > case Constants.ATTR_STACK_MAP_TABLE: > return new StackMapTable(name_index, length, file, constant_pool); >- case Constants.ATTR_BOOTSTRAP_METHODS: >- Utility.swallowBootstrapMethods(file); >- return null; >- case Constants.ATTR_METHOD_PARAMETERS: >- Utility.swallowMethodParameters(file); >- return null; > default: // Never reached > throw new IllegalStateException("Unrecognized attribute type tag parsed: " + tag); > } >diff --git a/classfile/AttributeReader.java b/classfile/AttributeReader.java >index ee18932..2b7172a 100644 >--- a/classfile/AttributeReader.java >+++ b/classfile/AttributeReader.java >@@ -23,6 +23,7 @@ package org.apache.tomcat.util.bcel.classfile; > * method. These factory objects should implement this interface. > > * @see Attribute >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > */ > public interface AttributeReader { >@@ -51,6 +52,6 @@ public interface AttributeReader { > it to construct an attribute. In the case of errors, a null can be > returned which will cause the parsing of the class file to fail. > */ >- Attribute createAttribute( int name_index, int length, java.io.DataInputStream file, >+ Attribute createAttribute( int name_index, int length, java.io.DataInput file, > ConstantPool constant_pool ); > } >diff --git a/classfile/ClassElementValue.java b/classfile/ClassElementValue.java >index 0008796..716981c 100644 >--- a/classfile/ClassElementValue.java >+++ b/classfile/ClassElementValue.java >@@ -17,6 +17,7 @@ > */ > package org.apache.tomcat.util.bcel.classfile; > >+import java.io.DataOutput; > import java.io.DataOutputStream; > import java.io.IOException; > >@@ -45,7 +46,7 @@ public class ClassElementValue extends ElementValue > } > > @Override >- public void dump(DataOutputStream dos) throws IOException >+ public void dump(DataOutput dos) throws IOException > { > dos.writeByte(type); // u1 kind of value > dos.writeShort(idx); >diff --git a/classfile/ClassFormatException.java b/classfile/ClassFormatException.java >index 542da08..527c555 100644 >--- a/classfile/ClassFormatException.java >+++ b/classfile/ClassFormatException.java >@@ -22,6 +22,7 @@ package org.apache.tomcat.util.bcel.classfile; > * that the file is malformed or otherwise cannot be interpreted as a > * class file. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > */ > public class ClassFormatException extends RuntimeException { >diff --git a/classfile/ClassParser.java b/classfile/ClassParser.java >index 479e7cb..4254c43 100644 >--- a/classfile/ClassParser.java >+++ b/classfile/ClassParser.java >@@ -17,15 +17,13 @@ > */ > package org.apache.tomcat.util.bcel.classfile; > >-import java.io.BufferedInputStream; >-import java.io.DataInputStream; >-import java.io.FileInputStream; >-import java.io.IOException; >-import java.io.InputStream; >+import java.io.*; >+import java.util.Arrays; > import java.util.zip.ZipEntry; > import java.util.zip.ZipFile; > > import org.apache.tomcat.util.bcel.Constants; >+import org.apache.tomcat.util.bcel.util.FastDataInputStream; > > /** > * Wrapper class that parses a given Java .class file. The method <A >@@ -39,11 +37,15 @@ import org.apache.tomcat.util.bcel.Constants; > * JVM specification 1.0</a>. See this paper for > * further details about the structure of a bytecode file. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > */ > public final class ClassParser { >+ >+ //switch for FastDataInputStream >+ public static boolean isFDIS = false; > >- private DataInputStream file; >+ private DataInput file; > private boolean fileOwned; > private String file_name; > private String zip_file; >@@ -70,10 +72,19 @@ public final class ClassParser { > fileOwned = false; > String clazz = file.getClass().getName(); // Not a very clean solution ... > is_zip = clazz.startsWith("java.util.zip.") || clazz.startsWith("java.util.jar."); >- if (file instanceof DataInputStream) { >- this.file = (DataInputStream) file; >- } else { >- this.file = new DataInputStream(new BufferedInputStream(file, BUFSIZE)); >+ if(isFDIS){ >+ if (file instanceof FastDataInputStream) { >+ this. >+ file = (FastDataInputStream) file; >+ } else { >+ this.file = new FastDataInputStream(file, BUFSIZE); >+ } >+ } else{ >+ if (file instanceof DataInputStream) { >+ this.file = (DataInputStream) file; >+ } else { >+ this.file = new DataInputStream(new BufferedInputStream(file, BUFSIZE)); >+ } > } > } > >@@ -93,20 +104,38 @@ public final class ClassParser { > ZipFile zip = null; > try { > if (fileOwned) { >- if (is_zip) { >- zip = new ZipFile(zip_file); >- ZipEntry entry = zip.getEntry(file_name); >- >- if (entry == null) { >- throw new IOException("File " + file_name + " not found"); >+ if(isFDIS){ >+ if (is_zip) { >+ zip = new ZipFile(zip_file); >+ ZipEntry entry = zip.getEntry(file_name); >+ >+ if (entry == null) { >+ throw new IOException("File " + file_name + " not found"); >+ } >+ >+ file = new FastDataInputStream(zip.getInputStream(entry), >+ BUFSIZE); >+ } else { >+ file = new FastDataInputStream(new FileInputStream( >+ file_name), BUFSIZE); >+ } >+ } >+ else { >+ if (is_zip) { >+ zip = new ZipFile(zip_file); >+ ZipEntry entry = zip.getEntry(file_name); >+ >+ if (entry == null) { >+ throw new IOException("File " + file_name + " not found"); >+ } >+ >+ file = new DataInputStream(new BufferedInputStream(zip.getInputStream(entry), >+ BUFSIZE)); >+ } else { >+ file = new DataInputStream(new BufferedInputStream(new FileInputStream( >+ file_name), BUFSIZE)); > } >- >- file = new DataInputStream(new BufferedInputStream(zip.getInputStream(entry), >- BUFSIZE)); >- } else { >- file = new DataInputStream(new BufferedInputStream(new FileInputStream( >- file_name), BUFSIZE)); >- } >+ } > } > /****************** Read headers ********************************/ > // Check magic tag of class file >@@ -145,8 +174,8 @@ public final class ClassParser { > // Read everything of interest, so close the file > if (fileOwned) { > try { >- if (file != null) { >- file.close(); >+ if (file != null && file instanceof Closeable) { >+ ((Closeable)file).close(); > } > if (zip != null) { > zip.close(); >@@ -167,7 +196,7 @@ public final class ClassParser { > * @throws IOException > * @throws ClassFormatException > */ >- private void readAttributes() throws IOException, ClassFormatException { >+ private final void readAttributes() throws IOException, ClassFormatException { > int attributes_count; > attributes_count = file.readUnsignedShort(); > attributes = new Attribute[attributes_count]; >@@ -182,7 +211,7 @@ public final class ClassParser { > * @throws IOException > * @throws ClassFormatException > */ >- private void readClassInfo() throws IOException, ClassFormatException { >+ private final void readClassInfo() throws IOException, ClassFormatException { > access_flags = file.readUnsignedShort(); > /* Interfaces are implicitely abstract, the flag should be set > * according to the JVM specification. >@@ -204,7 +233,7 @@ public final class ClassParser { > * @throws IOException > * @throws ClassFormatException > */ >- private void readConstantPool() throws IOException, ClassFormatException { >+ private final void readConstantPool() throws IOException, ClassFormatException { > constant_pool = new ConstantPool(file); > } > >@@ -214,7 +243,7 @@ public final class ClassParser { > * @throws IOException > * @throws ClassFormatException > */ >- private void readFields() throws IOException, ClassFormatException { >+ private final void readFields() throws IOException, ClassFormatException { > int fields_count; > fields_count = file.readUnsignedShort(); > fields = new Field[fields_count]; >@@ -223,6 +252,8 @@ public final class ClassParser { > } > } > >+ private static final byte[] MAGIC_ID = new byte[] { (byte)0xCA, (byte)0xFE, (byte)0xBA, (byte)0xBE}; >+ > > /******************** Private utility methods **********************/ > /** >@@ -231,11 +262,16 @@ public final class ClassParser { > * @throws IOException > * @throws ClassFormatException > */ >- private void readID() throws IOException, ClassFormatException { >- int magic = 0xCAFEBABE; >- if (file.readInt() != magic) { >+ private final void readID() throws IOException, ClassFormatException { >+ byte[] bytes = new byte[4]; >+ file.readFully(bytes); >+ if (!Arrays.equals(bytes, MAGIC_ID)) { > throw new ClassFormatException(file_name + " is not a Java .class file"); > } >+// int magic = 0xCAFEBABE; >+// if (file.readInt() != magic) { >+// throw new ClassFormatException(file_name + " is not a Java .class file"); >+// } > } > > >@@ -244,7 +280,7 @@ public final class ClassParser { > * @throws IOException > * @throws ClassFormatException > */ >- private void readInterfaces() throws IOException, ClassFormatException { >+ private final void readInterfaces() throws IOException, ClassFormatException { > int interfaces_count; > interfaces_count = file.readUnsignedShort(); > interfaces = new int[interfaces_count]; >@@ -259,7 +295,7 @@ public final class ClassParser { > * @throws IOException > * @throws ClassFormatException > */ >- private void readMethods() throws IOException, ClassFormatException { >+ private final void readMethods() throws IOException, ClassFormatException { > int methods_count; > methods_count = file.readUnsignedShort(); > methods = new Method[methods_count]; >@@ -274,7 +310,7 @@ public final class ClassParser { > * @throws IOException > * @throws ClassFormatException > */ >- private void readVersion() throws IOException, ClassFormatException { >+ private final void readVersion() throws IOException, ClassFormatException { > minor = file.readUnsignedShort(); > major = file.readUnsignedShort(); > } >diff --git a/classfile/Code.java b/classfile/Code.java >index e4fcf47..202ec56 100644 >--- a/classfile/Code.java >+++ b/classfile/Code.java >@@ -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; >@@ -34,6 +34,7 @@ import org.apache.tomcat.util.bcel.Constants; > * is used for debugging purposes and <em>LocalVariableTable</em> which > * contains information about the local variables. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see Attribute > * @see CodeException >@@ -59,14 +60,20 @@ public final class Code extends Attribute { > * @param file Input stream > * @param constant_pool Array of constants > */ >- Code(int name_index, int length, DataInputStream file, ConstantPool constant_pool) >+ Code(int name_index, int length, DataInput file, ConstantPool constant_pool) > throws IOException { >- // Initialize with some default values which will be overwritten later >+ // Initialize with some default values which will be overwritten later > this(name_index, length, file.readUnsignedShort(), file.readUnsignedShort(), (byte[]) null, > (CodeException[]) null, (Attribute[]) null, constant_pool); >+// System.out.println("init"); > code_length = file.readInt(); >+// System.out.println("readInt"); >+ >+// System.out.println("+++++++++++++++++"+code_length+"+++++++++++++++++"); >+ > code = new byte[code_length]; // Read byte code > file.readFully(code); >+ > /* Read exception table that contains all regions where an exception > * handler is active, i.e., a try { ... } catch() block. > */ >@@ -103,7 +110,7 @@ public final class Code extends Attribute { > */ > public Code(int name_index, int length, int max_stack, int max_locals, byte[] code, > CodeException[] exception_table, Attribute[] attributes, ConstantPool constant_pool) { >- super(Constants.ATTR_CODE, name_index, length, constant_pool); >+ super(Constants.ATTR_CODE, name_index, length, constant_pool); > this.max_stack = max_stack; > this.max_locals = max_locals; > setCode(code); >@@ -129,7 +136,7 @@ public final class Code extends Attribute { > * @return the internal length of this code attribute (minus the first 6 bytes) > * and excluding all its attributes > */ >- private int getInternalLength() { >+ private final int getInternalLength() { > return 2 /*max_stack*/+ 2 /*max_locals*/+ 4 /*code length*/ > + code_length /*byte-code*/ > + 2 /*exception-table length*/ >@@ -142,7 +149,7 @@ public final class Code extends Attribute { > * @return the full size of this code attribute, minus its first 6 bytes, > * including the size of all its contained attributes > */ >- private int calculateLength() { >+ private final int calculateLength() { > int len = 0; > for (int i = 0; i < attributes_count; i++) { > len += attributes[i].length + 6 /*attribute header size*/; >diff --git a/classfile/CodeException.java b/classfile/CodeException.java >index b5f9b19..72f7a91 100644 >--- a/classfile/CodeException.java >+++ b/classfile/CodeException.java >@@ -29,6 +29,7 @@ import org.apache.tomcat.util.bcel.Constants; > * attribute and is used only there. It contains a range in which a > * particular exception handler is active. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see Code > */ >diff --git a/classfile/Constant.java b/classfile/Constant.java >index 4db9f72..6d47dc8 100644 >--- a/classfile/Constant.java >+++ b/classfile/Constant.java >@@ -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.io.Serializable; > >@@ -29,6 +29,7 @@ import org.apache.tomcat.util.bcel.util.BCELComparator; > * in the constant pool of a class file. The classes keep closely to > * the JVM specification. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > */ > public abstract class Constant implements Cloneable, Serializable { >@@ -85,9 +86,9 @@ public abstract class Constant implements Cloneable, Serializable { > > > @Override >- public Object clone() { >+ public Constant clone() { > try { >- return super.clone(); >+ return (Constant) super.clone(); > } catch (CloneNotSupportedException e) { > throw new Error("Clone Not Supported"); // never happens > } >@@ -100,7 +101,7 @@ public abstract class Constant implements Cloneable, Serializable { > * @param file Input stream > * @return Constant object > */ >- static Constant readConstant( DataInputStream file ) throws IOException, >+ static final Constant readConstant( DataInput file ) throws IOException, > ClassFormatException { > byte b = file.readByte(); // Read tag byte > switch (b) { >diff --git a/classfile/ConstantCP.java b/classfile/ConstantCP.java >index 4a903f4..c827c90 100644 >--- a/classfile/ConstantCP.java >+++ b/classfile/ConstantCP.java >@@ -23,6 +23,7 @@ import java.io.IOException; > /** > * Abstract super class for Fieldref and Methodref constants. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see ConstantFieldref > * @see ConstantMethodref >diff --git a/classfile/ConstantClass.java b/classfile/ConstantClass.java >index 6ec6678..f2f4b83 100644 >--- a/classfile/ConstantClass.java >+++ b/classfile/ConstantClass.java >@@ -27,6 +27,7 @@ import org.apache.tomcat.util.bcel.Constants; > * <A HREF="org.apache.tomcat.util.bcel.classfile.Constant.html">Constant</A> class > * and represents a reference to a (external) class. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see Constant > */ >diff --git a/classfile/ConstantDouble.java b/classfile/ConstantDouble.java >index a2656ee..3b58abe 100644 >--- a/classfile/ConstantDouble.java >+++ b/classfile/ConstantDouble.java >@@ -27,6 +27,7 @@ import org.apache.tomcat.util.bcel.Constants; > * <A HREF="org.apache.tomcat.util.bcel.classfile.Constant.html">Constant</A> class > * and represents a reference to a Double object. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see Constant > */ >diff --git a/classfile/ConstantFieldref.java b/classfile/ConstantFieldref.java >index 62e23e6..1425d71 100644 >--- a/classfile/ConstantFieldref.java >+++ b/classfile/ConstantFieldref.java >@@ -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; >@@ -25,6 +25,7 @@ import org.apache.tomcat.util.bcel.Constants; > /** > * This class represents a constant pool reference to a field. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > */ > public final class ConstantFieldref extends ConstantCP { >@@ -38,7 +39,7 @@ public final class ConstantFieldref extends ConstantCP { > * @param file input stream > * @throws IOException > */ >- ConstantFieldref(DataInputStream file) throws IOException { >+ ConstantFieldref(DataInput file) throws IOException { > super(Constants.CONSTANT_Fieldref, file); > } > } >diff --git a/classfile/ConstantFloat.java b/classfile/ConstantFloat.java >index 56656b0..3f65cff 100644 >--- a/classfile/ConstantFloat.java >+++ b/classfile/ConstantFloat.java >@@ -27,6 +27,7 @@ import org.apache.tomcat.util.bcel.Constants; > * <A HREF="org.apache.tomcat.util.bcel.classfile.Constant.html">Constant</A> class > * and represents a reference to a float object. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see Constant > */ >diff --git a/classfile/ConstantInteger.java b/classfile/ConstantInteger.java >index 098314f..39a4353 100644 >--- a/classfile/ConstantInteger.java >+++ b/classfile/ConstantInteger.java >@@ -27,6 +27,7 @@ import org.apache.tomcat.util.bcel.Constants; > * <A HREF="org.apache.tomcat.util.bcel.classfile.Constant.html">Constant</A> class > * and represents a reference to an int object. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see Constant > */ >diff --git a/classfile/ConstantInterfaceMethodref.java b/classfile/ConstantInterfaceMethodref.java >index 8ee6869..cff450f 100644 >--- a/classfile/ConstantInterfaceMethodref.java >+++ b/classfile/ConstantInterfaceMethodref.java >@@ -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; >@@ -25,6 +25,7 @@ import org.apache.tomcat.util.bcel.Constants; > /** > * This class represents a constant pool reference to an interface method. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > */ > public final class ConstantInterfaceMethodref extends ConstantCP { >@@ -38,7 +39,8 @@ public final class ConstantInterfaceMethodref extends ConstantCP { > * @param file input stream > * @throws IOException > */ >- ConstantInterfaceMethodref(DataInputStream file) throws IOException { >+ ConstantInterfaceMethodref(DataInput file) throws IOException { > super(Constants.CONSTANT_InterfaceMethodref, file); > } >+ > } >diff --git a/classfile/ConstantLong.java b/classfile/ConstantLong.java >index d1eeb2a..4e9c52b 100644 >--- a/classfile/ConstantLong.java >+++ b/classfile/ConstantLong.java >@@ -27,6 +27,7 @@ import org.apache.tomcat.util.bcel.Constants; > * <A HREF="org.apache.tomcat.util.bcel.classfile.Constant.html">Constant</A> class > * and represents a reference to a long object. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see Constant > */ >diff --git a/classfile/ConstantMethodref.java b/classfile/ConstantMethodref.java >index 8aaaa43..8a473f0 100644 >--- a/classfile/ConstantMethodref.java >+++ b/classfile/ConstantMethodref.java >@@ -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; >@@ -25,6 +25,7 @@ import org.apache.tomcat.util.bcel.Constants; > /** > * This class represents a constant pool reference to a method. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > */ > public final class ConstantMethodref extends ConstantCP { >@@ -38,7 +39,7 @@ public final class ConstantMethodref extends ConstantCP { > * @param file input stream > * @throws IOException > */ >- ConstantMethodref(DataInputStream file) throws IOException { >+ ConstantMethodref(DataInput file) throws IOException { > super(Constants.CONSTANT_Methodref, file); > } > } >diff --git a/classfile/ConstantNameAndType.java b/classfile/ConstantNameAndType.java >index c125e52..a9181da 100644 >--- a/classfile/ConstantNameAndType.java >+++ b/classfile/ConstantNameAndType.java >@@ -28,6 +28,7 @@ import org.apache.tomcat.util.bcel.Constants; > * and represents a reference to the name and signature > * of a field or method. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see Constant > */ >diff --git a/classfile/ConstantPool.java b/classfile/ConstantPool.java >index 9fe96fd..2e50d3e 100644 >--- a/classfile/ConstantPool.java >+++ b/classfile/ConstantPool.java >@@ -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.io.Serializable; > >@@ -31,6 +31,7 @@ import org.apache.tomcat.util.bcel.Constants; > * programatically should see <a href="../generic/ConstantPoolGen.html"> > * ConstantPoolGen</a>. > >+ * @version $Id$ > * @see Constant > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > */ >@@ -48,7 +49,7 @@ public class ConstantPool implements Cloneable, Serializable { > * @throws IOException > * @throws ClassFormatException > */ >- ConstantPool(DataInputStream file) throws IOException, ClassFormatException { >+ ConstantPool(DataInput file) throws IOException, ClassFormatException { > byte tag; > constant_pool_count = file.readUnsignedShort(); > constant_pool = new Constant[constant_pool_count]; >@@ -128,7 +129,7 @@ public class ConstantPool implements Cloneable, Serializable { > } > > >- private static String escape( String str ) { >+ private static final String escape( String str ) { > int len = str.length(); > StringBuilder buf = new StringBuilder(len + 5); > char[] ch = str.toCharArray(); >diff --git a/classfile/ConstantString.java b/classfile/ConstantString.java >index 684d2c9..c7ea17e 100644 >--- a/classfile/ConstantString.java >+++ b/classfile/ConstantString.java >@@ -27,6 +27,7 @@ import org.apache.tomcat.util.bcel.Constants; > * <A HREF="org.apache.tomcat.util.bcel.classfile.Constant.html">Constant</A> class > * and represents a reference to a String object. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see Constant > */ >diff --git a/classfile/ConstantUtf8.java b/classfile/ConstantUtf8.java >index f467848..adaadcc 100644 >--- a/classfile/ConstantUtf8.java >+++ b/classfile/ConstantUtf8.java >@@ -17,7 +17,6 @@ > package org.apache.tomcat.util.bcel.classfile; > > import java.io.DataInput; >-import java.io.DataInputStream; > import java.io.IOException; > import java.util.HashMap; > import java.util.LinkedHashMap; >@@ -30,6 +29,7 @@ import org.apache.tomcat.util.bcel.Constants; > * <A HREF="org.apache.tomcat.util.bcel.classfile.Constant.html">Constant</A> class > * and represents a reference to a Utf8 encoded string. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see Constant > */ >@@ -69,7 +69,7 @@ public final class ConstantUtf8 extends Constant { > return getCachedInstance(s); > } > >- static ConstantUtf8 getInstance(DataInputStream file) throws IOException { >+ static ConstantUtf8 getInstance(DataInput file) throws IOException { > return getInstance(file.readUTF()); > } > >diff --git a/classfile/ConstantValue.java b/classfile/ConstantValue.java >index 722ee6e..6176147 100644 >--- a/classfile/ConstantValue.java >+++ b/classfile/ConstantValue.java >@@ -26,6 +26,7 @@ import org.apache.tomcat.util.bcel.Constants; > * value, i.e., a default value for initializing a class field. > * This class is instantiated by the <em>Attribute.readAttribute()</em> method. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see Attribute > */ >diff --git a/classfile/Deprecated.java b/classfile/Deprecated.java >index 4e10cc5..c3f184d 100644 >--- a/classfile/Deprecated.java >+++ b/classfile/Deprecated.java >@@ -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; >@@ -27,6 +27,7 @@ import org.apache.tomcat.util.bcel.Constants; > * deprecated method. > * It is instantiated from the <em>Attribute.readAttribute()</em> method. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see Attribute > */ >@@ -56,7 +57,7 @@ public final class Deprecated extends Attribute { > * @param constant_pool Array of constants > * @throws IOException > */ >- Deprecated(int name_index, int length, DataInputStream file, ConstantPool constant_pool) >+ Deprecated(int name_index, int length, DataInput file, ConstantPool constant_pool) > throws IOException { > this(name_index, length, (byte[]) null, constant_pool); > if (length > 0) { >diff --git a/classfile/ElementValue.java b/classfile/ElementValue.java >index f258e7f..39f3469 100644 >--- a/classfile/ElementValue.java >+++ b/classfile/ElementValue.java >@@ -17,13 +17,14 @@ > */ > package org.apache.tomcat.util.bcel.classfile; > >-import java.io.DataInputStream; >-import java.io.DataOutputStream; >+import java.io.DataInput; >+import java.io.DataOutput; > import java.io.IOException; > > /** >+ * @version $Id: ElementValue > * @author <A HREF="mailto:dbrosius@qis.net">D. Brosius</A> >- * @since 6.0 >+ * @since 5.3 > */ > public abstract class ElementValue > { >@@ -46,7 +47,7 @@ public abstract class ElementValue > > public abstract String stringifyValue(); > >- public abstract void dump(DataOutputStream dos) throws IOException; >+ public abstract void dump(DataOutput dos) throws IOException; > > public static final int STRING = 's'; > >@@ -74,7 +75,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(); >diff --git a/classfile/ElementValuePair.java b/classfile/ElementValuePair.java >index 4172fb7..46c62fb 100644 >--- a/classfile/ElementValuePair.java >+++ b/classfile/ElementValuePair.java >@@ -17,7 +17,7 @@ > */ > package org.apache.tomcat.util.bcel.classfile; > >-import java.io.DataOutputStream; >+import java.io.DataOutput; > import java.io.IOException; > > import org.apache.tomcat.util.bcel.Constants; >@@ -25,8 +25,9 @@ import org.apache.tomcat.util.bcel.Constants; > /** > * an annotation's element value pair > * >+ * @version $Id: ElementValuePair > * @author <A HREF="mailto:dbrosius@qis.net">D. Brosius</A> >- * @since 6.0 >+ * @since 5.3 > */ > public class ElementValuePair > { >@@ -56,7 +57,7 @@ public class ElementValuePair > return elementValue; > } > >- protected void dump(DataOutputStream dos) throws IOException { >+ protected void dump(DataOutput dos) throws IOException { > dos.writeShort(elementNameIndex); // u2 name of the element > elementValue.dump(dos); > } >diff --git a/classfile/EnclosingMethod.java b/classfile/EnclosingMethod.java >index 679faae..a57e253 100644 >--- a/classfile/EnclosingMethod.java >+++ b/classfile/EnclosingMethod.java >@@ -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; >@@ -30,7 +30,7 @@ public class EnclosingMethod extends Attribute { > private static final long serialVersionUID = 6755214228300933233L; > > // Ctors - and code to read an attribute in. >- public EnclosingMethod(int nameIndex, int len, DataInputStream dis, >+ public EnclosingMethod(int nameIndex, int len, DataInput dis, > ConstantPool cpool) throws IOException { > super(Constants.ATTR_ENCLOSING_METHOD, nameIndex, len, cpool); > // Unused class index >diff --git a/classfile/EnumElementValue.java b/classfile/EnumElementValue.java >index d91561c..8bb8d08 100644 >--- a/classfile/EnumElementValue.java >+++ b/classfile/EnumElementValue.java >@@ -17,7 +17,7 @@ > */ > package org.apache.tomcat.util.bcel.classfile; > >-import java.io.DataOutputStream; >+import java.io.DataOutput; > import java.io.IOException; > > import org.apache.tomcat.util.bcel.Constants; >@@ -41,7 +41,7 @@ public class EnumElementValue extends ElementValue > } > > @Override >- public void dump(DataOutputStream dos) throws IOException >+ public void dump(DataOutput dos) throws IOException > { > dos.writeByte(type); // u1 type of value (ENUM_CONSTANT == 'e') > dos.writeShort(typeIdx); // u2 >diff --git a/classfile/ExceptionTable.java b/classfile/ExceptionTable.java >index 613904b..57d718f 100644 >--- a/classfile/ExceptionTable.java >+++ b/classfile/ExceptionTable.java >@@ -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; >@@ -30,6 +30,7 @@ import org.apache.tomcat.util.bcel.Constants; > * attribute using the name <em>Exceptions</em> (which is inconsistent > * with the other classes). > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see Code > */ >@@ -61,7 +62,7 @@ public final class ExceptionTable extends Attribute { > * @param constant_pool Array of constants > * @throws IOException > */ >- ExceptionTable(int name_index, int length, DataInputStream file, ConstantPool constant_pool) >+ ExceptionTable(int name_index, int length, DataInput file, ConstantPool constant_pool) > throws IOException { > this(name_index, length, (int[]) null, constant_pool); > number_of_exceptions = file.readUnsignedShort(); >diff --git a/classfile/Field.java b/classfile/Field.java >index b5567e3..13949b3 100644 >--- a/classfile/Field.java >+++ b/classfile/Field.java >@@ -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; >@@ -27,6 +27,7 @@ import org.apache.tomcat.util.bcel.util.BCELComparator; > * This class represents the field info structure, i.e., the representation > * for a variable in the class. See JVM specification for details. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > */ > public final class Field extends FieldOrMethod { >@@ -55,7 +56,7 @@ public final class Field extends FieldOrMethod { > * Construct object from file stream. > * @param file Input stream > */ >- Field(DataInputStream file, ConstantPool constant_pool) throws IOException, >+ Field(DataInput file, ConstantPool constant_pool) throws IOException, > ClassFormatException { > super(file, constant_pool); > } >diff --git a/classfile/FieldOrMethod.java b/classfile/FieldOrMethod.java >index cdfe270..5adb685 100644 >--- a/classfile/FieldOrMethod.java >+++ b/classfile/FieldOrMethod.java >@@ -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; >@@ -25,6 +25,7 @@ import org.apache.tomcat.util.bcel.Constants; > /** > * Abstract super class for fields and methods. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > */ > public abstract class FieldOrMethod extends AccessFlags implements Cloneable { >@@ -47,7 +48,7 @@ public abstract class FieldOrMethod extends AccessFlags implements Cloneable { > * @throws IOException > * @throws ClassFormatException > */ >- protected FieldOrMethod(DataInputStream file, ConstantPool constant_pool) throws IOException, >+ protected FieldOrMethod(DataInput file, ConstantPool constant_pool) throws IOException, > ClassFormatException { > this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), null, > constant_pool); >diff --git a/classfile/InnerClass.java b/classfile/InnerClass.java >index 063303a..f65cd2a 100644 >--- a/classfile/InnerClass.java >+++ b/classfile/InnerClass.java >@@ -29,6 +29,7 @@ import org.apache.tomcat.util.bcel.Constants; > * indices of the inner and outer classes, the name and the attributes > * of the inner class. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see InnerClasses > */ >diff --git a/classfile/InnerClasses.java b/classfile/InnerClasses.java >index 81d99b3..a343183 100644 >--- a/classfile/InnerClasses.java >+++ b/classfile/InnerClasses.java >@@ -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; >@@ -28,6 +28,7 @@ import org.apache.tomcat.util.bcel.Constants; > * to the source file of this class. > * It is instantiated from the <em>Attribute.readAttribute()</em> method. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see Attribute > */ >@@ -60,7 +61,7 @@ public final class InnerClasses extends Attribute { > * @param constant_pool Array of constants > * @throws IOException > */ >- InnerClasses(int name_index, int length, DataInputStream file, ConstantPool constant_pool) >+ InnerClasses(int name_index, int length, DataInput file, ConstantPool constant_pool) > throws IOException { > this(name_index, length, (InnerClass[]) null, constant_pool); > number_of_classes = file.readUnsignedShort(); >diff --git a/classfile/JavaClass.java b/classfile/JavaClass.java >index 4744d3d..2149dbc 100644 >--- a/classfile/JavaClass.java >+++ b/classfile/JavaClass.java >@@ -32,6 +32,7 @@ import org.apache.tomcat.util.bcel.util.BCELComparator; > * class file. Those interested in programatically generating classes > * should see the <a href="../generic/ClassGen.html">ClassGen</a> class. > >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > */ > public class JavaClass extends AccessFlags >@@ -156,7 +157,8 @@ public class JavaClass extends AccessFlags > // Find attributes that contain annotation data > Attribute[] attrs = getAttributes(); > List<AnnotationEntry> accumulatedAnnotations = new ArrayList<AnnotationEntry>(); >- for (Attribute attribute : attrs) { >+ for (int i = 0; i < attrs.length; i++) { >+ Attribute attribute = attrs[i]; > if (attribute instanceof Annotations) { > Annotations runtimeAnnotations = (Annotations)attribute; > for(int j = 0; j < runtimeAnnotations.getAnnotationEntries().length; j++) >diff --git a/classfile/LineNumber.java b/classfile/LineNumber.java >index dbe1ef8..be24182 100644 >--- a/classfile/LineNumber.java >+++ b/classfile/LineNumber.java >@@ -27,6 +27,7 @@ import java.io.Serializable; > * the source that corresponds to a relative address in the byte code. This > * is used for debugging purposes. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see LineNumberTable > */ >diff --git a/classfile/LineNumberTable.java b/classfile/LineNumberTable.java >index a4079fa..0443046 100644 >--- a/classfile/LineNumberTable.java >+++ b/classfile/LineNumberTable.java >@@ -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; >@@ -27,6 +27,7 @@ import org.apache.tomcat.util.bcel.Constants; > * purposes. This attribute is used by the <em>Code</em> attribute. It > * contains pairs of PCs and line numbers. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see Code > * @see LineNumber >@@ -59,7 +60,7 @@ public final class LineNumberTable extends Attribute { > * @param constant_pool Array of constants > * @throws IOException > */ >- LineNumberTable(int name_index, int length, DataInputStream file, ConstantPool constant_pool) >+ LineNumberTable(int name_index, int length, DataInput file, ConstantPool constant_pool) > throws IOException { > this(name_index, length, (LineNumber[]) null, constant_pool); > line_number_table_length = (file.readUnsignedShort()); >diff --git a/classfile/LocalVariable.java b/classfile/LocalVariable.java >index 6da8f2c..6f47280 100644 >--- a/classfile/LocalVariable.java >+++ b/classfile/LocalVariable.java >@@ -28,6 +28,7 @@ import org.apache.tomcat.util.bcel.Constants; > * This class represents a local variable within a method. It contains its > * scope, name, signature and index on the method's frame. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see LocalVariableTable > */ >diff --git a/classfile/LocalVariableTable.java b/classfile/LocalVariableTable.java >index 91dd126..e13623c 100644 >--- a/classfile/LocalVariableTable.java >+++ b/classfile/LocalVariableTable.java >@@ -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; >@@ -26,6 +26,7 @@ import org.apache.tomcat.util.bcel.Constants; > * This class represents colection of local variables in a > * method. This attribute is contained in the <em>Code</em> attribute. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see Code > * @see LocalVariable >@@ -58,7 +59,7 @@ public class LocalVariableTable extends Attribute { > * @param constant_pool Array of constants > * @throws IOException > */ >- LocalVariableTable(int name_index, int length, DataInputStream file, ConstantPool constant_pool) >+ LocalVariableTable(int name_index, int length, DataInput file, ConstantPool constant_pool) > throws IOException { > this(name_index, length, (LocalVariable[]) null, constant_pool); > local_variable_table_length = (file.readUnsignedShort()); >diff --git a/classfile/LocalVariableTypeTable.java b/classfile/LocalVariableTypeTable.java >index 2581b2f..7e2b38e 100644 >--- a/classfile/LocalVariableTypeTable.java >+++ b/classfile/LocalVariableTypeTable.java >@@ -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; >@@ -61,7 +61,7 @@ private int local_variable_type_table_length; // Table of local > setLocalVariableTable(local_variable_table); > } > >- LocalVariableTypeTable(int nameIdx, int len, DataInputStream dis,ConstantPool cpool) throws IOException { >+ LocalVariableTypeTable(int nameIdx, int len, DataInput dis,ConstantPool cpool) throws IOException { > this(nameIdx, len, (LocalVariable[])null, cpool); > > local_variable_type_table_length = (dis.readUnsignedShort()); >diff --git a/classfile/Method.java b/classfile/Method.java >index dd6f8cf..e5b4bbc 100644 >--- a/classfile/Method.java >+++ b/classfile/Method.java >@@ -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; >@@ -28,6 +28,7 @@ import org.apache.tomcat.util.bcel.util.BCELComparator; > * for a method in the class. See JVM specification for details. > * A method has access flags, a name, a signature and a number of attributes. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > */ > public final class Method extends FieldOrMethod { >@@ -66,7 +67,7 @@ public final class Method extends FieldOrMethod { > * @throws IOException > * @throws ClassFormatException > */ >- Method(DataInputStream file, ConstantPool constant_pool) throws IOException, >+ Method(DataInput file, ConstantPool constant_pool) throws IOException, > ClassFormatException { > super(file, constant_pool); > } >diff --git a/classfile/PMGClass.java b/classfile/PMGClass.java >index 6ed145b..0ce4de2 100644 >--- a/classfile/PMGClass.java >+++ b/classfile/PMGClass.java >@@ -26,6 +26,7 @@ import org.apache.tomcat.util.bcel.Constants; > * This class is derived from <em>Attribute</em> and represents a reference > * to a PMG attribute. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see Attribute > */ >diff --git a/classfile/ParameterAnnotationEntry.java b/classfile/ParameterAnnotationEntry.java >index 7e07109..0d2846d 100644 >--- a/classfile/ParameterAnnotationEntry.java >+++ b/classfile/ParameterAnnotationEntry.java >@@ -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; >@@ -25,8 +25,9 @@ import org.apache.tomcat.util.bcel.Constants; > /** > * represents one parameter annotation in the parameter annotation table > * >+ * @version $Id: ParameterAnnotationEntry > * @author <A HREF="mailto:dbrosius@qis.net">D. Brosius</A> >- * @since 6.0 >+ * @since 5.3 > */ > public class ParameterAnnotationEntry implements Constants { > >@@ -39,7 +40,7 @@ public class ParameterAnnotationEntry implements Constants { > * @param file Input stream > * @throws IOException > */ >- ParameterAnnotationEntry(DataInputStream file, ConstantPool constant_pool) throws IOException { >+ ParameterAnnotationEntry(DataInput file, ConstantPool constant_pool) throws IOException { > annotation_table_length = (file.readUnsignedShort()); > annotation_table = new AnnotationEntry[annotation_table_length]; > for (int i = 0; i < annotation_table_length; i++) { >diff --git a/classfile/ParameterAnnotations.java b/classfile/ParameterAnnotations.java >index 82d593f..0d015f8 100644 >--- a/classfile/ParameterAnnotations.java >+++ b/classfile/ParameterAnnotations.java >@@ -17,14 +17,15 @@ > */ > package org.apache.tomcat.util.bcel.classfile; > >-import java.io.DataInputStream; >+import java.io.DataInput; > import java.io.IOException; > > /** > * base class for parameter annotations > * >+ * @version $Id: ParameterAnnotations > * @author <A HREF="mailto:dbrosius@qis.net">D. Brosius</A> >- * @since 6.0 >+ * @since 5.3 > */ > public abstract class ParameterAnnotations extends Attribute { > >@@ -41,7 +42,7 @@ public abstract class ParameterAnnotations extends Attribute { > * @param constant_pool Array of constants > */ > ParameterAnnotations(byte parameter_annotation_type, int name_index, int length, >- DataInputStream file, ConstantPool constant_pool) throws IOException { >+ DataInput file, ConstantPool constant_pool) throws IOException { > this(parameter_annotation_type, name_index, length, (ParameterAnnotationEntry[]) null, > constant_pool); > num_parameters = (file.readUnsignedByte()); >diff --git a/classfile/RuntimeInvisibleAnnotations.java b/classfile/RuntimeInvisibleAnnotations.java >index f56927c..bb6637b 100644 >--- a/classfile/RuntimeInvisibleAnnotations.java >+++ b/classfile/RuntimeInvisibleAnnotations.java >@@ -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; >@@ -26,8 +26,9 @@ import org.apache.tomcat.util.bcel.Constants; > * represents an annotation that is represented in the class file but is not > * provided to the JVM. > * >+ * @version $Id: RuntimeInvisibleAnnotations > * @author <A HREF="mailto:dbrosius@qis.net">D. Brosius</A> >- * @since 6.0 >+ * @since 5.3 > */ > public class RuntimeInvisibleAnnotations extends Annotations > { >@@ -44,10 +45,10 @@ public class RuntimeInvisibleAnnotations extends Annotations > * Array of constants > */ > RuntimeInvisibleAnnotations(int name_index, int length, >- DataInputStream file, ConstantPool constant_pool) >+ DataInput file, ConstantPool constant_pool) > throws IOException > { >- super(Constants.ATTR_RUNTIME_INVISIBLE_ANNOTATIONS, name_index, length, >+ super(Constants.ATTR_RUNTIMEIN_VISIBLE_ANNOTATIONS, name_index, length, > file, constant_pool); > } > >diff --git a/classfile/RuntimeInvisibleParameterAnnotations.java b/classfile/RuntimeInvisibleParameterAnnotations.java >index d7bca29..85b98eb 100644 >--- a/classfile/RuntimeInvisibleParameterAnnotations.java >+++ b/classfile/RuntimeInvisibleParameterAnnotations.java >@@ -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; >@@ -26,8 +26,9 @@ import org.apache.tomcat.util.bcel.Constants; > * represents a parameter annotation that is represented in the class file > * but is not provided to the JVM. > * >+ * @version $Id: RuntimeInvisibleParameterAnnotations > * @author <A HREF="mailto:dbrosius@qis.net">D. Brosius</A> >- * @since 6.0 >+ * @since 5.3 > */ > public class RuntimeInvisibleParameterAnnotations extends ParameterAnnotations { > >@@ -40,9 +41,9 @@ public class RuntimeInvisibleParameterAnnotations extends ParameterAnnotations { > * @param file Input stream > * @param constant_pool Array of constants > */ >- RuntimeInvisibleParameterAnnotations(int name_index, int length, DataInputStream file, >+ RuntimeInvisibleParameterAnnotations(int name_index, int length, DataInput file, > ConstantPool constant_pool) throws IOException { >- super(Constants.ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS, name_index, length, file, >+ super(Constants.ATTR_RUNTIMEIN_VISIBLE_PARAMETER_ANNOTATIONS, name_index, length, file, > constant_pool); > } > >diff --git a/classfile/RuntimeVisibleAnnotations.java b/classfile/RuntimeVisibleAnnotations.java >index dce7814..87e16cb 100644 >--- a/classfile/RuntimeVisibleAnnotations.java >+++ b/classfile/RuntimeVisibleAnnotations.java >@@ -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; >@@ -26,8 +26,9 @@ import org.apache.tomcat.util.bcel.Constants; > * represents an annotation that is represented in the class file and is > * provided to the JVM. > * >+ * @version $Id: RuntimeVisibleAnnotations > * @author <A HREF="mailto:dbrosius@qis.net">D. Brosius</A> >- * @since 6.0 >+ * @since 5.3 > */ > public class RuntimeVisibleAnnotations extends Annotations > { >@@ -44,7 +45,7 @@ public class RuntimeVisibleAnnotations extends Annotations > * Array of constants > */ > public RuntimeVisibleAnnotations(int name_index, int length, >- DataInputStream file, ConstantPool constant_pool) >+ DataInput file, ConstantPool constant_pool) > throws IOException > { > super(Constants.ATTR_RUNTIME_VISIBLE_ANNOTATIONS, name_index, length, >diff --git a/classfile/RuntimeVisibleParameterAnnotations.java b/classfile/RuntimeVisibleParameterAnnotations.java >index 0e71df2..286d53b 100644 >--- a/classfile/RuntimeVisibleParameterAnnotations.java >+++ b/classfile/RuntimeVisibleParameterAnnotations.java >@@ -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; >@@ -26,8 +26,9 @@ import org.apache.tomcat.util.bcel.Constants; > * represents a parameter annotation that is represented in the class file > * and is provided to the JVM. > * >+ * @version $Id: RuntimeVisibleParameterAnnotations > * @author <A HREF="mailto:dbrosius@qis.net">D. Brosius</A> >- * @since 6.0 >+ * @since 5.3 > */ > public class RuntimeVisibleParameterAnnotations extends ParameterAnnotations { > >@@ -40,7 +41,7 @@ public class RuntimeVisibleParameterAnnotations extends ParameterAnnotations { > * @param file Input stream > * @param constant_pool Array of constants > */ >- RuntimeVisibleParameterAnnotations(int name_index, int length, DataInputStream file, >+ RuntimeVisibleParameterAnnotations(int name_index, int length, DataInput file, > ConstantPool constant_pool) throws IOException { > super(Constants.ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS, name_index, length, file, > constant_pool); >diff --git a/classfile/Signature.java b/classfile/Signature.java >index 19b8dc7..134b85f 100644 >--- a/classfile/Signature.java >+++ b/classfile/Signature.java >@@ -26,6 +26,7 @@ import org.apache.tomcat.util.bcel.Constants; > * This class is derived from <em>Attribute</em> and represents a reference > * to a GJ attribute. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see Attribute > */ >diff --git a/classfile/SimpleElementValue.java b/classfile/SimpleElementValue.java >index d866193..5b185b7 100644 >--- a/classfile/SimpleElementValue.java >+++ b/classfile/SimpleElementValue.java >@@ -17,7 +17,7 @@ > */ > package org.apache.tomcat.util.bcel.classfile; > >-import java.io.DataOutputStream; >+import java.io.DataOutput; > import java.io.IOException; > > import org.apache.tomcat.util.bcel.Constants; >@@ -100,7 +100,7 @@ public class SimpleElementValue extends ElementValue > } > > @Override >- public void dump(DataOutputStream dos) throws IOException >+ public void dump(DataOutput dos) throws IOException > { > dos.writeByte(type); // u1 kind of value > switch (type) >diff --git a/classfile/SourceFile.java b/classfile/SourceFile.java >index 96b5783..07e3bd0 100644 >--- a/classfile/SourceFile.java >+++ b/classfile/SourceFile.java >@@ -28,6 +28,7 @@ import org.apache.tomcat.util.bcel.Constants; > * should appear per classfile. The intention of this class is that it is > * instantiated from the <em>Attribute.readAttribute()</em> method. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see Attribute > */ >diff --git a/classfile/StackMap.java b/classfile/StackMap.java >index 820f8f1..5eb31bb 100644 >--- a/classfile/StackMap.java >+++ b/classfile/StackMap.java >@@ -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; >@@ -31,6 +31,7 @@ import org.apache.tomcat.util.bcel.Constants; > * within the Code attribute of a method. See CLDC specification > * §5.3.1.2 > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see Code > * @see StackMapEntry >@@ -63,7 +64,7 @@ public final class StackMap extends Attribute { > * @param constant_pool Array of constants > * @throws IOException > */ >- StackMap(int name_index, int length, DataInputStream file, ConstantPool constant_pool) >+ StackMap(int name_index, int length, DataInput file, ConstantPool constant_pool) > throws IOException { > this(name_index, length, (StackMapEntry[]) null, constant_pool); > map_length = file.readUnsignedShort(); >diff --git a/classfile/StackMapEntry.java b/classfile/StackMapEntry.java >index a40ffda..bdebefb 100644 >--- a/classfile/StackMapEntry.java >+++ b/classfile/StackMapEntry.java >@@ -17,16 +17,14 @@ > */ > package org.apache.tomcat.util.bcel.classfile; > >-import java.io.DataInputStream; >-import java.io.DataOutputStream; >-import java.io.IOException; >-import java.io.Serializable; >+import java.io.*; > > /** > * This class represents a stack map entry recording the types of > * local variables and the the of stack items at a given byte code offset. > * See CLDC specification §5.3.1.2 > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see StackMap > * @see StackMapType >@@ -47,7 +45,7 @@ public final class StackMapEntry implements Cloneable, Serializable { > * @param file Input stream > * @throws IOException > */ >- StackMapEntry(DataInputStream file, ConstantPool constant_pool) throws IOException { >+ StackMapEntry(DataInput file, ConstantPool constant_pool) throws IOException { > this(file.readShort(), file.readShort(), null, -1, null); > types_of_locals = new StackMapType[number_of_locals]; > for (int i = 0; i < number_of_locals; i++) { >diff --git a/classfile/StackMapTable.java b/classfile/StackMapTable.java >index da69e61..ee448f4 100644 >--- a/classfile/StackMapTable.java >+++ b/classfile/StackMapTable.java >@@ -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; >@@ -31,6 +31,7 @@ import org.apache.tomcat.util.bcel.Constants; > * within the Code attribute of a method. See CLDC specification > * §5.3.1.2 > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see Code > * @see StackMapEntry >@@ -63,7 +64,7 @@ public final class StackMapTable extends Attribute { > * @param constant_pool Array of constants > * @throws IOException > */ >- StackMapTable(int name_index, int length, DataInputStream file, ConstantPool constant_pool) >+ StackMapTable(int name_index, int length, DataInput file, ConstantPool constant_pool) > throws IOException { > this(name_index, length, (StackMapTableEntry[]) null, constant_pool); > map_length = file.readUnsignedShort(); >diff --git a/classfile/StackMapTableEntry.java b/classfile/StackMapTableEntry.java >index 58e28fd..11c8653 100644 >--- a/classfile/StackMapTableEntry.java >+++ b/classfile/StackMapTableEntry.java >@@ -17,10 +17,7 @@ > */ > package org.apache.tomcat.util.bcel.classfile; > >-import java.io.DataInputStream; >-import java.io.DataOutputStream; >-import java.io.IOException; >-import java.io.Serializable; >+import java.io.*; > > import org.apache.tomcat.util.bcel.Constants; > >@@ -29,6 +26,7 @@ import org.apache.tomcat.util.bcel.Constants; > * local variables and the the of stack items at a given byte code offset. > * See CLDC specification §5.3.1.2 > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see StackMap > * @see StackMapType >@@ -50,8 +48,8 @@ public final class StackMapTableEntry implements Cloneable, Serializable { > * @param file Input stream > * @throws IOException > */ >- StackMapTableEntry(DataInputStream file, ConstantPool constant_pool) throws IOException { >- this(file.read(), -1, -1, null, -1, null); >+ StackMapTableEntry(DataInput file, ConstantPool constant_pool) throws IOException { >+ this(file.readUnsignedByte(), -1, -1, null, -1, null); > > if (frame_type >= Constants.SAME_FRAME && frame_type <= Constants.SAME_FRAME_MAX) { > byte_code_offset_delta = frame_type - Constants.SAME_FRAME; >diff --git a/classfile/StackMapType.java b/classfile/StackMapType.java >index 7c8816e..93d9009 100644 >--- a/classfile/StackMapType.java >+++ b/classfile/StackMapType.java >@@ -28,6 +28,7 @@ import org.apache.tomcat.util.bcel.Constants; > * This class represents the type of a local variable or item on stack > * used in the StackMap entries. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see StackMapEntry > * @see StackMap >diff --git a/classfile/Synthetic.java b/classfile/Synthetic.java >index 8ec4b92..0122ecb 100644 >--- a/classfile/Synthetic.java >+++ b/classfile/Synthetic.java >@@ -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; >@@ -31,6 +31,7 @@ import org.apache.tomcat.util.bcel.Constants; > * is intended to be instantiated from the > * <em>Attribute.readAttribute()</em> method. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > * @see Attribute > */ >@@ -62,7 +63,7 @@ public final class Synthetic extends Attribute { > * @param constant_pool Array of constants > * @throws IOException > */ >- Synthetic(int name_index, int length, DataInputStream file, ConstantPool constant_pool) >+ Synthetic(int name_index, int length, DataInput file, ConstantPool constant_pool) > throws IOException { > this(name_index, length, (byte[]) null, constant_pool); > if (length > 0) { >diff --git a/classfile/Unknown.java b/classfile/Unknown.java >index d61ac0b..11e7d13 100644 >--- a/classfile/Unknown.java >+++ b/classfile/Unknown.java >@@ -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.HashMap; > import java.util.Map; >@@ -35,6 +35,7 @@ import org.apache.tomcat.util.bcel.Constants; > * org.apache.tomcat.util.bcel.classfile.AttributeReader)">Attribute.addAttributeReader</a>. > > * >+ * @version $Id$ > * @see org.apache.tomcat.util.bcel.classfile.Attribute > * @see org.apache.tomcat.util.bcel.classfile.AttributeReader > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> >@@ -73,7 +74,7 @@ public final class Unknown extends Attribute { > * @param constant_pool Array of constants > * @throws IOException > */ >- Unknown(int name_index, int length, DataInputStream file, ConstantPool constant_pool) >+ Unknown(int name_index, int length, DataInput file, ConstantPool constant_pool) > throws IOException { > this(name_index, length, (byte[]) null, constant_pool); > if (length > 0) { >diff --git a/classfile/Utility.java b/classfile/Utility.java >index 75caa96..f83b04a 100644 >--- a/classfile/Utility.java >+++ b/classfile/Utility.java >@@ -17,7 +17,6 @@ > */ > package org.apache.tomcat.util.bcel.classfile; > >-import java.io.DataInput; > import java.io.IOException; > > import org.apache.tomcat.util.bcel.Constants; >@@ -26,6 +25,7 @@ import org.apache.tomcat.util.bcel.util.ByteSequence; > /** > * Utility functions that do not really belong to any class in particular. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > */ > public abstract class Utility { >@@ -778,23 +778,4 @@ public abstract class Utility { > } > return buf.toString(); > } >- >- static void swallowBootstrapMethods(DataInput file) throws IOException { >- int num_bootstrap_methods = file.readUnsignedShort(); >- for (int i = 0; i < num_bootstrap_methods; i++) { >- file.readUnsignedShort(); // Unused bootstrap_method_ref >- int num_bootstrap_args = file.readUnsignedShort(); >- for (int j = 0; j < num_bootstrap_args; j++) { >- file.readUnsignedShort(); // Unused bootstrap method argument >- } >- } >- } >- >- static void swallowMethodParameters(DataInput file) throws IOException { >- int parameters_count = file.readUnsignedByte(); >- for (int i = 0; i < parameters_count; i++) { >- file.readUnsignedShort(); // Unused name_index >- file.readUnsignedShort(); // Unused access_flags >- } >- } > } >diff --git a/classfile/package.html b/classfile/package.html >index 4a9c4b3..e82c2d9 100644 >--- a/classfile/package.html >+++ b/classfile/package.html >@@ -17,6 +17,9 @@ > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> > <html> > <head> >+<!-- >+$Id$ >+--> > </head> > <body bgcolor="white"> > <p> >diff --git a/util/BCELComparator.java b/util/BCELComparator.java >index 3e92a8d..2d68865 100644 >--- a/util/BCELComparator.java >+++ b/util/BCELComparator.java >@@ -21,6 +21,7 @@ package org.apache.tomcat.util.bcel.util; > * Used for BCEL comparison strategy > * > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> >+ * @version $Id$ > * @since 5.2 > */ > public interface BCELComparator { >diff --git a/util/ByteSequence.java b/util/ByteSequence.java >index 00b0e5c..e0c8f38 100644 >--- a/util/ByteSequence.java >+++ b/util/ByteSequence.java >@@ -25,6 +25,7 @@ import java.io.DataInputStream; > * via the `readByte()' method. This is used to implement a wrapper for the > * Java byte code stream to gain some more readability. > * >+ * @version $Id$ > * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> > */ > public final class ByteSequence extends DataInputStream { >diff --git a/util/FastDataInputStream.java b/util/FastDataInputStream.java >new file mode 100644 >index 0000000..06dfea5 >--- /dev/null >+++ b/util/FastDataInputStream.java >@@ -0,0 +1,345 @@ >+/* >+ * Licensed to the Apache Software Foundation (ASF) under one or more >+ * contributor license agreements. See the NOTICE file distributed with >+ * this work for additional information regarding copyright ownership. >+ * The ASF licenses this file to You under the Apache License, Version 2.0 >+ * (the "License"); you may not use this file except in compliance with >+ * the License. You may obtain a copy of the License at >+ * >+ * http://www.apache.org/licenses/LICENSE-2.0 >+ * >+ * Unless required by applicable law or agreed to in writing, software >+ * distributed under the License is distributed on an "AS IS" BASIS, >+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. >+ * See the License for the specific language governing permissions and >+ * limitations under the License. >+ */ >+ >+package org.apache.tomcat.util.bcel.util; >+ >+import java.io.DataInput; >+import java.io.EOFException; >+import java.io.FilterInputStream; >+import java.io.IOException; >+import java.io.InputStream; >+import java.io.UTFDataFormatException; >+ >+ >+/** >+ * Created by xshao on 7/31/14. >+ */ >+public class FastDataInputStream extends FilterInputStream implements DataInput { >+ /** >+ * Creates a DataInputStream that uses the specified >+ * underlying InputStream. >+ * >+ * @param in the specified input stream >+ * @throws IOException >+ */ >+ >+ //Buff >+ private static int defaultBufferSize = 8192; >+ protected volatile byte buf[]; >+ protected int cnt; >+ protected int pos; >+ >+ //Constructor >+ public FastDataInputStream(InputStream in) { >+ super(in); >+ buf = new byte[defaultBufferSize]; >+ } >+ >+ public FastDataInputStream(InputStream in, int size) { >+ super(in); >+ if (size <= 0) { >+ throw new IllegalArgumentException("Buffer size <= 0"); >+ } >+ buf = new byte[size]; >+ } >+ >+ public final int read(byte b[]) throws IOException { >+ return this.read(b, 0, b.length); >+ } >+ >+ public int read(byte b[], int off, int len) >+ throws IOException >+ { >+ if ((off | len | (off + len) | (b.length - (off + len))) < 0) { >+ throw new IndexOutOfBoundsException(); >+ } else if (len == 0) { >+ return 0; >+ } >+ >+ int n = 0; >+ for (;;) { >+ int nread = read1(b, off + n, len - n); >+ if (nread <= 0) >+ return (n == 0) ? nread : n; >+ n += nread; >+ if (n >= len) >+ return n; >+ // if not closed but no bytes available, return >+ InputStream input = in; >+ if (input != null && input.available() <= 0) >+ return n; >+ } >+ } >+ >+ private int read1(byte[] b, int off, int len) throws IOException { >+ int avail = cnt - pos; >+ if (avail <= 0) { >+ /* If the requested length is at least as large as the buffer, and >+ if there is no mark/reset activity, do not bother to copy the >+ bytes into the local buffer. In this way buffered streams will >+ cascade harmlessly. */ >+ if (len >= this.buf.length) { >+ return this.in.read(b, off, len); >+ } >+ fill(); >+ avail = cnt - pos; >+ if (avail <= 0) return -1; >+ } >+ int inc = (avail < len) ? avail : len; >+ System.arraycopy(this.buf, pos, b, off, inc); >+ pos += inc; >+ return inc; >+ } >+ >+ public final void readFully(byte b[]) throws IOException { >+// System.out.println("readFully"); >+ >+ readFully(b, 0, b.length); >+ } >+ >+ @Override >+ public final void readFully(byte b[], int off, int len) throws IOException { >+ if (len < 0) >+ throw new IndexOutOfBoundsException(); >+ int n = 0; >+ while (n < len) { >+ int count = this.read(b, off + n, len - n); >+ if (count < 0) >+ throw new EOFException(); >+ n += count; >+ } >+ } >+ >+ @Override >+ public boolean readBoolean() throws IOException { >+ if (pos >= cnt) { >+ fill(); >+ if (pos >= cnt) >+ throw new EOFException(); >+ } >+ int ch = this.buf[pos++] & 0xff; >+ return (ch != 0); >+ } >+ >+ public final byte readByte() throws IOException { >+// System.out.println("readByte"); >+ >+ if (pos >= cnt) { >+ fill(); >+ if (pos >= cnt) >+ throw new EOFException(); >+ } >+ return this.buf[pos++]; >+// int ch = this.buf[pos++] & 0xff; >+// return (byte)(ch); >+ } >+ >+ @Override >+ public int readUnsignedByte() throws IOException { >+ if (pos >= cnt) { >+ fill(); >+ if (pos >= cnt) >+ throw new EOFException(); >+ } >+ int ch = this.buf[pos++] & 0xff; >+ return ch; >+ } >+ >+ public final short readShort() throws IOException { >+// System.out.println("readShort"); >+ >+ if(pos + 1 >= cnt){ >+ fill(); >+ if(pos + 1 >= cnt) throw new EOFException(); >+ } >+ int ch1 = this.buf[pos++] & 0xff; >+ int ch2 = this.buf[pos++] & 0xff; >+ return (short)((ch1 << 8) + (ch2 << 0)); >+ } >+ >+ public int readUnsignedShort() throws IOException{ >+// System.out.println("readUnsignedShort"); >+ >+ if(pos + 1 >= cnt) { >+ fill(); >+ if(pos + 1 >= cnt) throw new EOFException(); >+ } >+ >+ int ch1 = this.buf[pos++] & 0xff; >+ int ch2 = this.buf[pos++] & 0xff; >+ return (ch1 << 8) + (ch2 << 0); >+ } >+ >+ public final char readChar() throws IOException { >+// System.out.println("readChar"); >+ >+ if(pos + 1 >= cnt) { >+ fill(); >+ if(pos + 1 >= cnt) throw new EOFException(); >+ } >+ int ch1 = this.buf[pos++] & 0xff; >+ int ch2 = this.buf[pos++] & 0xff; >+ return (char)((ch1 << 8) + (ch2 << 0)); >+ } >+ >+ public final int readInt() throws IOException { >+// System.out.println("readInt"); >+ >+ if(pos + 3 >= cnt){ >+ fill(); >+ if(pos + 3 >= cnt) throw new EOFException(); >+ } >+ int ch1 = this.buf[pos++] & 0xff; >+ int ch2 = this.buf[pos++] & 0xff; >+ int ch3 = this.buf[pos++] & 0xff; >+ int ch4 = this.buf[pos++] & 0xff; >+ return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0)); >+ } >+ >+ private byte readBuffer[] = new byte[8]; >+ >+ public final long readLong() throws IOException { >+ readFully(readBuffer, 0, 8); >+ return (((long)readBuffer[0] << 56) + >+ ((long)(readBuffer[1] & 255) << 48) + >+ ((long)(readBuffer[2] & 255) << 40) + >+ ((long)(readBuffer[3] & 255) << 32) + >+ ((long)(readBuffer[4] & 255) << 24) + >+ ((readBuffer[5] & 255) << 16) + >+ ((readBuffer[6] & 255) << 8) + >+ ((readBuffer[7] & 255) << 0)); >+ } >+ >+ public final float readFloat() throws IOException { >+ return Float.intBitsToFloat(readInt()); >+ } >+ >+ @Override >+ public double readDouble() throws IOException { >+ return Double.longBitsToDouble(readLong()); >+ } >+ >+ public final String readUTF() throws IOException { >+// System.out.println("readUTF"); >+ >+ return readUTF(this); >+ } >+ >+ private byte bytearr[] = new byte[80]; >+ private char chararr[] = new char[80]; >+ >+ public final String readUTF(DataInput in) throws IOException { >+ int utflen = this.readUnsignedShort(); >+ byte[] bytearr = null; >+ char[] chararr = null; >+ if (in instanceof FastDataInputStream) { >+ FastDataInputStream dis = (FastDataInputStream)in; >+ if (dis.bytearr.length < utflen){ >+ dis.bytearr = new byte[utflen*2]; >+ dis.chararr = new char[utflen*2]; >+ } >+ chararr = dis.chararr; >+ bytearr = dis.bytearr; >+ } else { >+ bytearr = new byte[utflen]; >+ chararr = new char[utflen]; >+ } >+ >+ int c, char2, char3; >+ int count = 0; >+ int chararr_count=0; >+ >+ this.readFully(bytearr, 0, utflen); >+ >+ while (count < utflen) { >+ c = (int) bytearr[count] & 0xff; >+ if (c > 127) break; >+ count++; >+ chararr[chararr_count++]=(char)c; >+ } >+ >+ while (count < utflen) { >+ c = (int) bytearr[count] & 0xff; >+ switch (c >> 4) { >+ case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: >+ /* 0xxxxxxx*/ >+ count++; >+ chararr[chararr_count++]=(char)c; >+ break; >+ case 12: case 13: >+ /* 110x xxxx 10xx xxxx*/ >+ count += 2; >+ if (count > utflen) >+ throw new UTFDataFormatException( >+ "malformed input: partial character at end"); >+ char2 = (int) bytearr[count-1]; >+ if ((char2 & 0xC0) != 0x80) >+ throw new UTFDataFormatException( >+ "malformed input around byte " + count); >+ chararr[chararr_count++]=(char)(((c & 0x1F) << 6) | >+ (char2 & 0x3F)); >+ break; >+ case 14: >+ /* 1110 xxxx 10xx xxxx 10xx xxxx */ >+ count += 3; >+ if (count > utflen) >+ throw new UTFDataFormatException( >+ "malformed input: partial character at end"); >+ char2 = (int) bytearr[count-2]; >+ char3 = (int) bytearr[count-1]; >+ if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80)) >+ throw new UTFDataFormatException( >+ "malformed input around byte " + (count-1)); >+ chararr[chararr_count++]=(char)(((c & 0x0F) << 12) | >+ ((char2 & 0x3F) << 6) | >+ ((char3 & 0x3F) << 0)); >+ break; >+ default: >+ /* 10xx xxxx, 1111 xxxx */ >+ throw new UTFDataFormatException( >+ "malformed input around byte " + count); >+ } >+ } >+ // The number of chars produced may be less than utflen >+ return new String(chararr, 0, chararr_count); >+ } >+ >+ private void fill() throws IOException { >+// System.out.println("fill"); >+ int remain = 0; >+ if(pos < cnt){ >+ remain = cnt - pos; >+ System.arraycopy(buf, cnt - remain, buf, 0, remain); >+ } >+ pos = 0; >+ int n = this.in.read(buf, remain, defaultBufferSize - remain); >+ cnt = pos + n + remain; >+ } >+ >+// unimplemented >+ @Override >+ public int skipBytes(int n) throws IOException { >+ // TODO Auto-generated method stub >+ throw new IOException(); >+ } >+ >+ @Override >+ public String readLine() throws IOException { >+ // TODO Auto-generated method stub >+ throw new IOException(); >+ } >+} >diff --git a/util/package.html b/util/package.html >index f3447bd..01618ec 100644 >--- a/util/package.html >+++ b/util/package.html >@@ -17,11 +17,14 @@ > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> > <html> > <head> >+<!-- >+$Id$ >+--> > </head> > <body bgcolor="white"> > <p> > This package contains utility classes for the >-<a href="http://commons.apache.org/bcel/">Byte Code Engineering >+<a href="http://jakarta.apache.org/bcel/">Byte Code Engineering > Library</a>, namely: > </p> > <p>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 56953
:
31993
|
31994
|
32008
|
32029
|
32030
|
32031