public AccessFlags() {
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
}
ElementValue default_value;
/**
- * @param annotation_type
- * the subclass type of the annotation
* @param name_index
* Index pointing to the name <em>Code</em>
* @param length
}
/**
- * @param annotation_type
- * the subclass type of the annotation
* @param name_index
* Index pointing to the name <em>Code</em>
* @param length
*/
public class AnnotationEntry implements Constants, Serializable {
+ private static final long serialVersionUID = 1L;
+
private int type_index;
- private int num_element_value_pairs;
- private List element_value_pairs;
private ConstantPool constant_pool;
private boolean isRuntimeVisible;
-
+ private List element_value_pairs;
+
/**
- * Construct object from file stream.
- * @param file Input stream
+ * Factory method to create an AnnotionEntry from a DataInputStream
+ *
+ * @param file
+ * @param constant_pool
+ * @param isRuntimeVisible
+ * @return
+ * @throws IOException
*/
- public AnnotationEntry(int type_index, ConstantPool constant_pool, boolean isRuntimeVisible) {
- this.type_index = type_index;
+ public static AnnotationEntry read(DataInputStream file, ConstantPool constant_pool, boolean isRuntimeVisible) throws IOException {
- this.constant_pool = constant_pool;
- this.isRuntimeVisible = isRuntimeVisible;
- }
-
- public static AnnotationEntry read(DataInputStream file, ConstantPool constant_pool, boolean isRuntimeVisible) throws IOException
- {
- AnnotationEntry annotationEntry = new AnnotationEntry(file.readUnsignedShort(), constant_pool, isRuntimeVisible);
- annotationEntry.num_element_value_pairs = (file.readUnsignedShort());
+ final AnnotationEntry annotationEntry = new AnnotationEntry(file.readUnsignedShort(), constant_pool, isRuntimeVisible);
+ final int num_element_value_pairs = (file.readUnsignedShort());
annotationEntry.element_value_pairs = new ArrayList();
- for (int i = 0; i < annotationEntry.num_element_value_pairs; i++) {
- annotationEntry.element_value_pairs.add(new ElementValuePair(file.readUnsignedShort(), ElementValue.readElementValue(file, constant_pool), constant_pool));
+ 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;
}
+ public AnnotationEntry(int type_index, ConstantPool constant_pool, boolean isRuntimeVisible) {
+ this.type_index = type_index;
+ this.constant_pool = constant_pool;
+ this.isRuntimeVisible = isRuntimeVisible;
+ }
+
/**
* @return the annotation type name
*/
public String getAnnotationType() {
- ConstantUtf8 c;
- c = (ConstantUtf8) constant_pool.getConstant(type_index, CONSTANT_Utf8);
+ final ConstantUtf8 c = (ConstantUtf8) constant_pool.getConstant(type_index, CONSTANT_Utf8);
return c.getBytes();
}
*/
public abstract class Annotations extends Attribute {
- private int annotation_table_length;
- private AnnotationEntry[] annotation_table; // Table of annotations
-
-
+ private static final long serialVersionUID = 1L;
+
+ private AnnotationEntry[] annotation_table;
+
/**
* @param annotation_type the subclass type of the annotation
* @param name_index Index pointing to the name <em>Code</em>
* @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, boolean isRuntimeVisible) throws IOException {
+ public Annotations(byte annotation_type, int name_index, int length, DataInputStream file, ConstantPool constant_pool, boolean isRuntimeVisible) throws IOException {
this(annotation_type, name_index, length, (AnnotationEntry[]) null, constant_pool);
- annotation_table_length = (file.readUnsignedShort());
+ 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, isRuntimeVisible);
* @param annotation_table the actual annotations
* @param constant_pool Array of constants
*/
- public Annotations(byte annotation_type, int name_index, int length,
- AnnotationEntry[] annotation_table, ConstantPool constant_pool) {
+ public Annotations(byte annotation_type, int name_index, int length, AnnotationEntry[] annotation_table, ConstantPool constant_pool) {
super(annotation_type, name_index, length, constant_pool);
setAnnotationTable(annotation_table);
}
-
/**
* @param annotation_table the entries to set in this annotation
*/
public final void setAnnotationTable( AnnotationEntry[] annotation_table ) {
this.annotation_table = annotation_table;
- annotation_table_length = (annotation_table == null) ? 0 : annotation_table.length;
}
-
- // TODO: update method names
- /**
- * @return the annotation entry table
- */
- /*
- public final AnnotationEntry[] getAnnotationTable() {
- return annotation_table;
- }*/
-
-
/**
* returns the array of annotation entries in this annotation
*/
return annotation_table;
}
-
-
-
-
-
- protected void writeAnnotations(DataOutputStream dos) throws IOException
- {
- dos.writeShort(annotation_table_length);
- for (int i = 0; i < annotation_table_length; i++)
+ protected void writeAnnotations(DataOutputStream dos) throws IOException {
+ if (annotation_table == null) {
+ return;
+ }
+ dos.writeShort(annotation_table.length);
+ for (int i = 0; i < annotation_table.length; i++)
annotation_table[i].dump(dos);
}
}
file.writeInt(length);
}
- private static Map readers = new HashMap();
-
-
-
-
+ private static final Map readers = new HashMap();
/*
* Class method reads one attribute from the input data stream. This method
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 {
{
return elementValue;
}
-
-
-
-
protected void dump(DataOutputStream dos) throws IOException {
dos.writeShort(elementNameIndex); // u2 name of the element
/**
- * @return first matching variable using index
*
* @param index the variable slot
*
return null;
}
-
-
-
-
public final void setLocalVariableTable( LocalVariable[] local_variable_table ) {
this.local_variable_table = local_variable_table;
local_variable_table_length = (local_variable_table == null)
annotation_table[i] = AnnotationEntry.read(file, constant_pool, false);
}
}
-
-
-
-
-
-
-
-
}
? 0
: parameter_annotation_table.length;
}
-
-
-
-
-
-
-
-
}
*/
public final void dump( DataOutputStream file ) throws IOException {
file.write(frame_type);
- if (frame_type >= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME && frame_type <= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) {
+ if (frame_type >= Constants.SAME_FRAME && frame_type <= Constants.SAME_FRAME_MAX) {
+ // nothing to be done
+ } else if (frame_type >= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME && frame_type <= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) {
types_of_stack_items[0].dump(file);
} else if (frame_type == Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) {
- file.write(byte_code_offset_delta);
+ file.writeShort(byte_code_offset_delta);
types_of_stack_items[0].dump(file);
} else if (frame_type >= Constants.CHOP_FRAME && frame_type <= Constants.CHOP_FRAME_MAX) {
- file.write(byte_code_offset_delta);
+ file.writeShort(byte_code_offset_delta);
} else if (frame_type == Constants.SAME_FRAME_EXTENDED) {
- file.write(byte_code_offset_delta);
+ file.writeShort(byte_code_offset_delta);
} else if (frame_type >= Constants.APPEND_FRAME && frame_type <= Constants.APPEND_FRAME_MAX) {
- file.write(byte_code_offset_delta);
+ file.writeShort(byte_code_offset_delta);
for (int i = 0; i < number_of_locals; i++) {
types_of_locals[i].dump(file);
- }
+ }
} else if (frame_type == Constants.FULL_FRAME) {
file.writeShort(byte_code_offset_delta);
file.writeShort(number_of_locals);
private byte[] bytes;
private String name;
- private static Map unknown_attributes = new HashMap();
+ private static final Map unknown_attributes = new HashMap();
package org.apache.tomcat.util.bcel.classfile;
import java.io.IOException;
+
import org.apache.tomcat.util.bcel.Constants;
import org.apache.tomcat.util.bcel.util.ByteSequence;
/**
+ * @param access_flags the class flags
+ *
* @return "class" or "interface", depending on the ACC_INTERFACE flag
*/
public static final String classOrInterface( int access_flags ) {
* @param constant_pool Array of constants
* @param verbose be verbose, e.g. print constant pool index
* @return String representation of byte code
+ *
+ * @throws IOException if a failure from reading from the bytes argument occurs
*/
public static final String codeToString( ByteSequence bytes, ConstantPool constant_pool,
boolean verbose ) throws IOException {
case Constants.NEW:
case Constants.CHECKCAST:
buf.append("\t");
- /* FALL THRU */
+ //$FALL-THROUGH$
case Constants.INSTANCEOF:
index = bytes.readUnsignedShort();
buf.append("\t<").append(
return compactClassName(str, "java.lang.", chopit);
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/**
* A returntype signature represents the return value from a method.
* It is a series of bytes in the following grammar:
* @param signature Method signature
* @param name Method name
* @param access Method access rights
+ * @param chopit
+ * @param vars
* @return Java type declaration
* @throws ClassFormatException
*/
public static final String replace( String str, String old, String new_ ) {
int index, old_index;
try {
- if ((index = str.indexOf(old)) != -1) { // `old' found in str
+ if (str.indexOf(old) != -1) { // `old' found in str
StringBuffer buf = new StringBuffer();
old_index = 0; // String start offset
// While we have something to replace
}
}
-
-
-
-
-
-
-
-
-
-
/**
* Convert (signed) byte to (unsigned) short value, i.e., all negative
* values become positive.
}
- /** Convert bytes into hexidecimal string
+ /** Convert bytes into hexadecimal string
*
- * @return bytes as hexidecimal string, e.g. 00 FA 12 ...
+ * @param bytes an array of bytes to convert to hexadecimal
+ *
+ * @return bytes as hexadecimal string, e.g. 00 FA 12 ...
*/
public static final String toHexString( byte[] bytes ) {
StringBuffer buf = new StringBuffer();
return buf.toString();
}
-
-
-
-
/**
* Fillup char with up to length characters with char `fill' and justify it left or right.
*
return new String(buf) + str;
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// A-Z, g-z, _, $
private static final int FREE_CHARS = 48;
static int[] CHAR_MAP = new int[FREE_CHARS];
original commons-fileupload layout to make merging of future updates
easier. (markt)
</update>
+ <update>
+ Update the re-packaged version of Jakarta BCEL from trunk revision
+ 880760 to trunk revision 978831. (markt)
+ </update>
</changelog>
</subsection>
</section>