Skip to content

Commit

Permalink
Update packaged re-named Jakarta BCEL
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@981203 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
markt-asf committed Aug 1, 2010
1 parent a63d15e commit d590cb5
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 268 deletions.
101 changes: 0 additions & 101 deletions java/org/apache/tomcat/util/bcel/classfile/AccessFlags.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,105 +32,4 @@ public abstract class AccessFlags implements java.io.Serializable {
public AccessFlags() {
}






































































































}
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public class AnnotationDefault extends Attribute
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
Expand All @@ -55,8 +53,6 @@ public AnnotationDefault(int name_index, int length,
}

/**
* @param annotation_type
* the subclass type of the annotation
* @param name_index
* Index pointing to the name <em>Code</em>
* @param length
Expand Down
43 changes: 24 additions & 19 deletions java/org/apache/tomcat/util/bcel/classfile/AnnotationEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,41 +35,46 @@
*/
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();
}

Expand Down
44 changes: 13 additions & 31 deletions java/org/apache/tomcat/util/bcel/classfile/Annotations.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,20 @@
*/
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 length Content length in bytes
* @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);
Expand All @@ -59,48 +58,31 @@ public Annotations(byte annotation_type, int name_index, int length, DataInputSt
* @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
*/
public AnnotationEntry[] getAnnotationEntries() {
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);
}
}
6 changes: 1 addition & 5 deletions java/org/apache/tomcat/util/bcel/classfile/Attribute.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@ public void dump(DataOutputStream file) throws IOException
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
Expand Down
5 changes: 5 additions & 0 deletions java/org/apache/tomcat/util/bcel/classfile/ClassParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ public JavaClass parse() throws IOException, ClassFormatException {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ public final ElementValue getValue()
{
return elementValue;
}





protected void dump(DataOutputStream dos) throws IOException {
dos.writeShort(elementNameIndex); // u2 name of the element
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ public final void dump( DataOutputStream file ) throws IOException {


/**
* @return first matching variable using index
*
* @param index the variable slot
*
Expand All @@ -109,10 +108,6 @@ public final LocalVariable getLocalVariable( int index ) {
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,5 @@ public class ParameterAnnotationEntry implements Constants {
annotation_table[i] = AnnotationEntry.read(file, constant_pool, false);
}
}









}
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,5 @@ public final void setParameterAnnotationTable(
? 0
: parameter_annotation_table.length;
}









}
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,22 @@ public StackMapTableEntry(int tag, int byte_code_offset_delta, int number_of_loc
*/
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);
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/tomcat/util/bcel/classfile/Unknown.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public final class Unknown extends Attribute {

private byte[] bytes;
private String name;
private static Map unknown_attributes = new HashMap();
private static final Map unknown_attributes = new HashMap();



Expand Down

0 comments on commit d590cb5

Please sign in to comment.