@@ -34,205 +34,106 @@ public AccessFlags() {
}


/**
* @param a inital access flags
*/
public AccessFlags(int a) {
access_flags = a;
}



/**
* @return Access flags of the object aka. "modifiers".
*/
public final int getAccessFlags() {
return access_flags;
}



/**
* @return Access flags of the object aka. "modifiers".
*/
public final int getModifiers() {
return access_flags;
}



/** Set access flags aka "modifiers".
* @param access_flags Access flags of the object.
*/
public final void setAccessFlags( int access_flags ) {
this.access_flags = access_flags;
}



/** Set access flags aka "modifiers".
* @param access_flags Access flags of the object.
*/
public final void setModifiers( int access_flags ) {
setAccessFlags(access_flags);
}



private final void setFlag( int flag, boolean set ) {
if ((access_flags & flag) != 0) { // Flag is set already
if (!set) {
access_flags ^= flag;
}
} else { // Flag not set
if (set) {
access_flags |= flag;
}
}
}



public final void isPublic( boolean flag ) {
setFlag(Constants.ACC_PUBLIC, flag);
}



public final boolean isPublic() {
return (access_flags & Constants.ACC_PUBLIC) != 0;
}



public final void isPrivate( boolean flag ) {
setFlag(Constants.ACC_PRIVATE, flag);
}



public final boolean isPrivate() {
return (access_flags & Constants.ACC_PRIVATE) != 0;
}



public final void isProtected( boolean flag ) {
setFlag(Constants.ACC_PROTECTED, flag);
}



public final boolean isProtected() {
return (access_flags & Constants.ACC_PROTECTED) != 0;
}



public final void isStatic( boolean flag ) {
setFlag(Constants.ACC_STATIC, flag);
}



public final boolean isStatic() {
return (access_flags & Constants.ACC_STATIC) != 0;
}



public final void isFinal( boolean flag ) {
setFlag(Constants.ACC_FINAL, flag);
}



public final boolean isFinal() {
return (access_flags & Constants.ACC_FINAL) != 0;
}



public final void isSynchronized( boolean flag ) {
setFlag(Constants.ACC_SYNCHRONIZED, flag);
}



public final boolean isSynchronized() {
return (access_flags & Constants.ACC_SYNCHRONIZED) != 0;
}



public final void isVolatile( boolean flag ) {
setFlag(Constants.ACC_VOLATILE, flag);
}



public final boolean isVolatile() {
return (access_flags & Constants.ACC_VOLATILE) != 0;
}



public final void isTransient( boolean flag ) {
setFlag(Constants.ACC_TRANSIENT, flag);
}


public final boolean isTransient() {
return (access_flags & Constants.ACC_TRANSIENT) != 0;
}



public final void isNative( boolean flag ) {
setFlag(Constants.ACC_NATIVE, flag);
}



public final boolean isNative() {
return (access_flags & Constants.ACC_NATIVE) != 0;
}


public final void isInterface( boolean flag ) {
setFlag(Constants.ACC_INTERFACE, flag);
}



public final boolean isInterface() {
return (access_flags & Constants.ACC_INTERFACE) != 0;
}


public final void isAbstract( boolean flag ) {
setFlag(Constants.ACC_ABSTRACT, flag);
}



public final boolean isAbstract() {
return (access_flags & Constants.ACC_ABSTRACT) != 0;
}



public final void isStrictfp( boolean flag ) {
setFlag(Constants.ACC_STRICT, flag);
}



public final boolean isStrictfp() {
return (access_flags & Constants.ACC_STRICT) != 0;
}



public final void isSynthetic( boolean flag ) {
setFlag(Constants.ACC_SYNTHETIC, flag);
}



public final boolean isSynthetic() {
return (access_flags & Constants.ACC_SYNTHETIC) != 0;
}



public final void isAnnotation( boolean flag ) {
setFlag(Constants.ACC_ANNOTATION, flag);
}



public final boolean isAnnotation() {
return (access_flags & Constants.ACC_ANNOTATION) != 0;
}



public final void isEnum( boolean flag ) {
setFlag(Constants.ACC_ENUM, flag);
}



public final boolean isEnum() {
return (access_flags & Constants.ACC_ENUM) != 0;
}

}
@@ -94,13 +94,7 @@ public final void setDefaultValue(ElementValue defaultValue)
default_value = defaultValue;
}

/**
* @return the default value
*/
public final ElementValue getDefaultValue()
{
return default_value;
}


public Attribute copy(ConstantPool _constant_pool)
{
@@ -64,16 +64,7 @@ public static AnnotationEntry read(DataInputStream file, ConstantPool constant_p
}


/**
* Called by objects that are traversing the nodes of the tree implicitely
* defined by the contents of a Java class. I.e., the hierarchy of methods,
* fields, attributes, etc. spawns a tree of objects.
*
* @param v Visitor object
*/
public void accept( Visitor v ) {
// v.visitAnnotationEntry(this);
}



/**
@@ -94,12 +85,7 @@ public int getAnnotationTypeIndex()
}


/**
* @return the number of element value pairs in this annotation entry
*/
public final int getNumElementValuePairs() {
return num_element_value_pairs;
}



/**
@@ -132,21 +118,5 @@ public void addElementNameValuePair(ElementValuePair elementNameValuePair)
element_value_pairs.add(elementNameValuePair);
}

public String toShortString()
{
StringBuffer result = new StringBuffer();
result.append("@");
result.append(getAnnotationType());
if (getElementValuePairs().length > 0)
{
result.append("(");
for (int i = 0; i < getElementValuePairs().length; i++)
{
ElementValuePair element = getElementValuePairs()[i];
result.append(element.toShortString());
}
result.append(")");
}
return result.toString();
}

}
@@ -106,17 +106,9 @@ public AnnotationEntry[] getAnnotationEntries() {
}


/**
* @return the number of annotation entries in this annotation
*/
public final int getNumAnnotations() {
return annotation_table_length;
}

public boolean isRuntimeVisible()
{
return isRuntimeVisible;
}



protected void writeAnnotations(DataOutputStream dos) throws IOException
{
@@ -60,8 +60,5 @@ public ElementValue[] getElementValuesArray()
return evalues;
}

public int getElementValuesArraySize()
{
return evalues.length;
}

}
@@ -91,31 +91,9 @@ public void dump(DataOutputStream file) throws IOException

private static Map readers = new HashMap();

/**
* Add an Attribute reader capable of parsing (user-defined) attributes
* named "name". You should not add readers for the standard attributes such
* as "LineNumberTable", because those are handled internally.
*
* @param name
* the name of the attribute as stored in the class file
* @param r
* the reader object
*/
public static void addAttributeReader(String name, AttributeReader r)
{
readers.put(name, r);
}


/**
* Remove attribute reader
*
* @param name
* the name of the attribute as stored in the class file
*/
public static void removeAttributeReader(String name)
{
readers.remove(name);
}


/*
* Class method reads one attribute from the input data stream. This method
@@ -226,39 +204,13 @@ public String getName()
return c.getBytes();
}

/**
* @return Length of attribute field in bytes.
*/
public final int getLength()
{
return length;
}


/**
* @param length
* length in bytes.
*/
public final void setLength(int length)
{
this.length = length;
}


/**
* @param name_index
* of attribute.
*/
public final void setNameIndex(int name_index)
{
this.name_index = name_index;
}


/**
* @return Name index in constant pool of attribute name.
*/
public final int getNameIndex()
{
return name_index;
}


/**
* @return Tag of attribute, i.e., its type. Value may not be altered, thus
@@ -269,24 +221,9 @@ public final byte getTag()
return tag;
}

/**
* @return Constant pool used by this object.
* @see ConstantPool
*/
public final ConstantPool getConstantPool()
{
return constant_pool;
}


/**
* @param constant_pool
* Constant pool to be used for this object.
* @see ConstantPool
*/
public final void setConstantPool(ConstantPool constant_pool)
{
this.constant_pool = constant_pool;
}


/**
* Use copy() if you want to have a deep copy(), i.e., with all references
@@ -78,28 +78,10 @@ public ClassParser(InputStream file, String file_name) {
}


/** Parse class from given .class file.
*
* @param file_name file name
*/
public ClassParser(String file_name) {
is_zip = false;
this.file_name = file_name;
fileOwned = true;
}



/** Parse class from given .class file in a ZIP-archive
*
* @param zip_file zip file name
* @param file_name file name
*/
public ClassParser(String zip_file, String file_name) {
is_zip = true;
fileOwned = true;
this.zip_file = zip_file;
this.file_name = file_name;
}



/**
@@ -52,14 +52,7 @@ public final class Code extends Attribute {
private Attribute[] attributes; // or LocalVariable


/**
* Initialize from another object. Note that both objects use the same
* references (shallow copy). Use copy() for a physical copy.
*/
public Code(Code c) {
this(c.getNameIndex(), c.getLength(), c.getMaxStack(), c.getMaxLocals(), c.getCode(), c
.getExceptionTable(), c.getAttributes(), c.getConstantPool());
}



/**
@@ -156,26 +149,10 @@ public final void dump( DataOutputStream file ) throws IOException {
}


/**
* @return Collection of code attributes.
* @see Attribute
*/
public final Attribute[] getAttributes() {
return attributes;
}



/**
* @return LineNumberTable of Code, if it has one
*/
public LineNumberTable getLineNumberTable() {
for (int i = 0; i < attributes_count; i++) {
if (attributes[i] instanceof LineNumberTable) {
return (LineNumberTable) attributes[i];
}
}
return null;
}



/**
@@ -191,37 +168,16 @@ public LocalVariableTable getLocalVariableTable() {
}


/**
* @return Actual byte code of the method.
*/
public final byte[] getCode() {
return code;
}



/**
* @return Table of handled exceptions.
* @see CodeException
*/
public final CodeException[] getExceptionTable() {
return exception_table;
}



/**
* @return Number of local variables.
*/
public final int getMaxLocals() {
return max_locals;
}



/**
* @return Maximum size of stack used by this method.
*/
public final int getMaxStack() {
return max_stack;
}



/**
@@ -278,20 +234,10 @@ public final void setExceptionTable( CodeException[] exception_table ) {
}


/**
* @param max_locals maximum number of local variables
*/
public final void setMaxLocals( int max_locals ) {
this.max_locals = max_locals;
}



/**
* @param max_stack maximum stack size
*/
public final void setMaxStack( int max_stack ) {
this.max_stack = max_stack;
}



/**
@@ -45,12 +45,7 @@ public final class CodeException implements Cloneable, Constants, Node, Serializ
*/


/**
* Initialize from another object.
*/
public CodeException(CodeException c) {
this(c.getStartPC(), c.getEndPC(), c.getHandlerPC(), c.getCatchType());
}



/**
@@ -82,16 +77,7 @@ public CodeException(int start_pc, int end_pc, int handler_pc, int catch_type) {
}


/**
* Called by objects that are traversing the nodes of the tree implicitely
* defined by the contents of a Java class. I.e., the hierarchy of methods,
* fields, attributes, etc. spawns a tree of objects.
*
* @param v Visitor object
*/
public void accept( Visitor v ) {
v.visitCodeException(this);
}



/**
@@ -108,69 +94,28 @@ public final void dump( DataOutputStream file ) throws IOException {
}


/**
* @return 0, if the handler catches any exception, otherwise it points to
* the exception class which is to be caught.
*/
public final int getCatchType() {
return catch_type;
}



/**
* @return Exclusive end index of the region where the handler is active.
*/
public final int getEndPC() {
return end_pc;
}



/**
* @return Starting address of exception handler, relative to the code.
*/
public final int getHandlerPC() {
return handler_pc;
}



/**
* @return Inclusive start index of the region where the handler is active.
*/
public final int getStartPC() {
return start_pc;
}



/**
* @param catch_type the type of exception that is caught
*/
public final void setCatchType( int catch_type ) {
this.catch_type = catch_type;
}



/**
* @param end_pc end of handled block
*/
public final void setEndPC( int end_pc ) {
this.end_pc = end_pc;
}



/**
* @param handler_pc where the actual code is
*/
public final void setHandlerPC( int handler_pc ) {
this.handler_pc = handler_pc;
}



/**
* @param start_pc start of handled block
*/
public final void setStartPC( int start_pc ) {
this.start_pc = start_pc;
}



/**
@@ -197,9 +142,7 @@ public final String toString( ConstantPool cp, boolean verbose ) {
}


public final String toString( ConstantPool cp ) {
return toString(cp, true);
}



/**
@@ -93,16 +93,7 @@ public String toString() {
}


/**
* @return deep copy of this constant
*/
public Constant copy() {
try {
return (Constant) super.clone();
} catch (CloneNotSupportedException e) {
}
return null;
}



public Object clone() throws CloneNotSupportedException {
@@ -148,20 +139,10 @@ static final Constant readConstant( DataInputStream file ) throws IOException,
}


/**
* @return Comparison strategy object
*/
public static BCELComparator getComparator() {
return _cmp;
}



/**
* @param comparator Comparison strategy object
*/
public static void setComparator( BCELComparator comparator ) {
_cmp = comparator;
}



/**
@@ -20,8 +20,6 @@
import java.io.DataOutputStream;
import java.io.IOException;

import org.apache.tomcat.util.bcel.Constants;

/**
* Abstract super class for Fieldref and Methodref constants.
*
@@ -38,12 +36,7 @@ public abstract class ConstantCP extends Constant {
protected int class_index, name_and_type_index;


/**
* Initialize from another object.
*/
public ConstantCP(ConstantCP c) {
this(c.getTag(), c.getClassIndex(), c.getNameAndTypeIndex());
}



/**
@@ -98,28 +91,13 @@ public final int getNameAndTypeIndex() {
}


/**
* @param class_index points to Constant_class
*/
public final void setClassIndex( int class_index ) {
this.class_index = class_index;
}



/**
* @return Class this field belongs to.
*/
public String getClass( ConstantPool cp ) {
return cp.constantToString(class_index, Constants.CONSTANT_Class);
}



/**
* @param name_and_type_index points to Constant_NameAndType
*/
public final void setNameAndTypeIndex( int name_and_type_index ) {
this.name_and_type_index = name_and_type_index;
}



/**
@@ -36,12 +36,7 @@ public final class ConstantClass extends Constant implements ConstantObject {
private int name_index; // Identical to ConstantString except for the name


/**
* Initialize from another object.
*/
public ConstantClass(ConstantClass c) {
this(c.getNameIndex());
}



/**
@@ -97,27 +92,13 @@ public final int getNameIndex() {
}


/**
* @param name_index the name index in the constant pool of this Constant Class
*/
public final void setNameIndex( int name_index ) {
this.name_index = name_index;
}



/** @return String object
*/
public Object getConstantValue( ConstantPool cp ) {
Constant c = cp.getConstant(name_index, Constants.CONSTANT_Utf8);
return ((ConstantUtf8) c).getBytes();
}



/** @return dereferenced string
*/
public String getBytes( ConstantPool cp ) {
return (String) getConstantValue(cp);
}



/**
@@ -45,12 +45,7 @@ public ConstantDouble(double bytes) {
}


/**
* Initialize from another object.
*/
public ConstantDouble(ConstantDouble c) {
this(c.getBytes());
}



/**
@@ -96,12 +91,7 @@ public final double getBytes() {
}


/**
* @param bytes the raw bytes that represent the double value
*/
public final void setBytes( double bytes ) {
this.bytes = bytes;
}



/**
@@ -112,9 +102,5 @@ public final String toString() {
}


/** @return Double object
*/
public Object getConstantValue( ConstantPool cp ) {
return new Double(bytes);
}

}
@@ -28,12 +28,7 @@
*/
public final class ConstantFieldref extends ConstantCP {

/**
* Initialize from another object.
*/
public ConstantFieldref(ConstantFieldref c) {
super(Constants.CONSTANT_Fieldref, c.getClassIndex(), c.getNameAndTypeIndex());
}



/**
@@ -45,13 +45,7 @@ public ConstantFloat(float bytes) {
}


/**
* Initialize from another object. Note that both objects use the same
* references (shallow copy). Use clone() for a physical copy.
*/
public ConstantFloat(ConstantFloat c) {
this(c.getBytes());
}



/**
@@ -97,12 +91,7 @@ public final float getBytes() {
}


/**
* @param bytes the raw bytes that represent this float
*/
public final void setBytes( float bytes ) {
this.bytes = bytes;
}



/**
@@ -113,9 +102,5 @@ public final String toString() {
}


/** @return Float object
*/
public Object getConstantValue( ConstantPool cp ) {
return new Float(bytes);
}

}
@@ -45,12 +45,7 @@ public ConstantInteger(int bytes) {
}


/**
* Initialize from another object.
*/
public ConstantInteger(ConstantInteger c) {
this(c.getBytes());
}



/**
@@ -96,12 +91,7 @@ public final int getBytes() {
}


/**
* @param bytes the raw bytes that represent this integer
*/
public final void setBytes( int bytes ) {
this.bytes = bytes;
}



/**
@@ -112,9 +102,5 @@ public final String toString() {
}


/** @return Integer object
*/
public Object getConstantValue( ConstantPool cp ) {
return new Integer(bytes);
}

}
@@ -28,12 +28,7 @@
*/
public final class ConstantInterfaceMethodref extends ConstantCP {

/**
* Initialize from another object.
*/
public ConstantInterfaceMethodref(ConstantInterfaceMethodref c) {
super(Constants.CONSTANT_InterfaceMethodref, c.getClassIndex(), c.getNameAndTypeIndex());
}



/**
@@ -45,12 +45,7 @@ public ConstantLong(long bytes) {
}


/**
* Initialize from another object.
*/
public ConstantLong(ConstantLong c) {
this(c.getBytes());
}



/**
@@ -96,12 +91,7 @@ public final long getBytes() {
}


/**
* @param bytes thr raw bytes that represent this long
*/
public final void setBytes( long bytes ) {
this.bytes = bytes;
}



/**
@@ -112,9 +102,5 @@ public final String toString() {
}


/** @return Long object
*/
public Object getConstantValue( ConstantPool cp ) {
return new Long(bytes);
}

}
@@ -28,12 +28,7 @@
*/
public final class ConstantMethodref extends ConstantCP {

/**
* Initialize from another object.
*/
public ConstantMethodref(ConstantMethodref c) {
super(Constants.CONSTANT_Methodref, c.getClassIndex(), c.getNameAndTypeIndex());
}



/**
@@ -38,12 +38,7 @@ public final class ConstantNameAndType extends Constant {
private int signature_index; // and its signature.


/**
* Initialize from another object.
*/
public ConstantNameAndType(ConstantNameAndType c) {
this(c.getNameIndex(), c.getSignatureIndex());
}



/**
@@ -101,11 +96,7 @@ public final int getNameIndex() {
}


/** @return name
*/
public final String getName( ConstantPool cp ) {
return cp.constantToString(getNameIndex(), Constants.CONSTANT_Utf8);
}



/**
@@ -116,27 +107,13 @@ public final int getSignatureIndex() {
}


/** @return signature
*/
public final String getSignature( ConstantPool cp ) {
return cp.constantToString(getSignatureIndex(), Constants.CONSTANT_Utf8);
}



/**
* @param name_index the name index of this constant
*/
public final void setNameIndex( int name_index ) {
this.name_index = name_index;
}



/**
* @param signature_index the signature index in the constant pool of this type
*/
public final void setSignatureIndex( int signature_index ) {
this.signature_index = signature_index;
}



/**
@@ -26,7 +26,5 @@
*/
public interface ConstantObject {

/** @return object representing the constant, e.g., Long for ConstantLong
*/
public abstract Object getConstantValue( ConstantPool cp );

}
@@ -17,7 +17,6 @@
package org.apache.tomcat.util.bcel.classfile;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.Serializable;
import org.apache.tomcat.util.bcel.Constants;
@@ -80,16 +79,7 @@ public ConstantPool(Constant[] constant_pool) {
}


/**
* Called by objects that are traversing the nodes of the tree implicitely
* defined by the contents of a Java class. I.e., the hierarchy of methods,
* fields, attributes, etc. spawns a tree of objects.
*
* @param v Visitor object
*/
public void accept( Visitor v ) {
v.visitConstantPool(this);
}



/**
@@ -191,20 +181,7 @@ public String constantToString( int index, byte tag ) throws ClassFormatExceptio
}


/**
* Dump constant pool to file stream in binary format.
*
* @param file Output file stream
* @throws IOException
*/
public void dump( DataOutputStream file ) throws IOException {
file.writeShort(constant_pool_count);
for (int i = 1; i < constant_pool_count; i++) {
if (constant_pool[i] != null) {
constant_pool[i].dump(file);
}
}
}



/**
@@ -247,13 +224,7 @@ public Constant getConstant( int index, byte tag ) throws ClassFormatException {
}


/**
* @return Array of constants.
* @see Constant
*/
public Constant[] getConstantPool() {
return constant_pool;
}



/**
@@ -304,12 +275,7 @@ public int getLength() {
}


/**
* @param constant Constant to set
*/
public void setConstant( int index, Constant constant ) {
constant_pool[index] = constant;
}



/**
@@ -333,21 +299,5 @@ public String toString() {
}


/**
* @return deep copy of this constant pool
*/
public ConstantPool copy() {
ConstantPool c = null;
try {
c = (ConstantPool) clone();
c.constant_pool = new Constant[constant_pool_count];
for (int i = 1; i < constant_pool_count; i++) {
if (constant_pool[i] != null) {
c.constant_pool[i] = constant_pool[i].copy();
}
}
} catch (CloneNotSupportedException e) {
}
return c;
}

}
@@ -36,12 +36,7 @@ public final class ConstantString extends Constant implements ConstantObject {
private int string_index; // Identical to ConstantClass except for this name


/**
* Initialize from another object.
*/
public ConstantString(ConstantString c) {
this(c.getStringIndex());
}



/**
@@ -96,12 +91,7 @@ public final int getStringIndex() {
}


/**
* @param string_index the index into the constant of the string value
*/
public final void setStringIndex( int string_index ) {
this.string_index = string_index;
}



/**
@@ -112,17 +102,8 @@ public final String toString() {
}


/** @return String object
*/
public Object getConstantValue( ConstantPool cp ) {
Constant c = cp.getConstant(string_index, Constants.CONSTANT_Utf8);
return ((ConstantUtf8) c).getBytes();
}



/** @return dereferenced string
*/
public String getBytes( ConstantPool cp ) {
return (String) getConstantValue(cp);
}

}
@@ -36,12 +36,7 @@ public final class ConstantUtf8 extends Constant {
private String bytes;


/**
* Initialize from another object.
*/
public ConstantUtf8(ConstantUtf8 c) {
this(c.getBytes());
}



/**
@@ -100,12 +95,7 @@ public final String getBytes() {
}


/**
* @param bytes the raw bytes of this Utf-8
*/
public final void setBytes( String bytes ) {
this.bytes = bytes;
}



/**
@@ -36,13 +36,7 @@ public final class ConstantValue extends Attribute {
private int constantvalue_index;


/**
* Initialize from another object. Note that both objects use the same
* references (shallow copy). Use clone() for a physical copy.
*/
public ConstantValue(ConstantValue c) {
this(c.getNameIndex(), c.getLength(), c.getConstantValueIndex(), c.getConstantPool());
}



/**
@@ -96,20 +90,10 @@ public final void dump( DataOutputStream file ) throws IOException {
}


/**
* @return Index in constant pool of constant value.
*/
public final int getConstantValueIndex() {
return constantvalue_index;
}



/**
* @param constantvalue_index the index info the constant pool of this constant value
*/
public final void setConstantValueIndex( int constantvalue_index ) {
this.constantvalue_index = constantvalue_index;
}



/**
@@ -35,13 +35,7 @@ public final class Deprecated extends Attribute {
private byte[] bytes;


/**
* Initialize from another object. Note that both objects use the same
* references (shallow copy). Use clone() for a physical copy.
*/
public Deprecated(Deprecated c) {
this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool());
}



/**
@@ -101,20 +95,10 @@ public final void dump( DataOutputStream file ) throws IOException {
}


/**
* @return data bytes.
*/
public final byte[] getBytes() {
return bytes;
}



/**
* @param bytes the raw bytes that represents this byte array
*/
public final void setBytes( byte[] bytes ) {
this.bytes = bytes;
}



/**
@@ -133,10 +133,5 @@ public static ElementValue readElementValue(DataInputStream dis,
}
}

public String toShortString()
{
StringBuffer result = new StringBuffer();
result.append(stringifyValue());
return result.toString();
}

}
@@ -60,13 +60,7 @@ public int getNameIndex()
return elementNameIndex;
}

public String toShortString()
{
StringBuffer result = new StringBuffer();
result.append(getNameString()).append("=").append(
getValue().toShortString());
return result.toString();
}


protected void dump(DataOutputStream dos) throws IOException {
dos.writeShort(elementNameIndex); // u2 name of the element
@@ -59,25 +59,15 @@ public Attribute copy(ConstantPool constant_pool) {
// return (EnclosingMethod)clone();
}

// Accessors
public final int getEnclosingClassIndex() { return classIndex; }
public final int getEnclosingMethodIndex(){ return methodIndex;}





public final void setEnclosingClassIndex(int idx) {classIndex = idx;}
public final void setEnclosingMethodIndex(int idx){methodIndex= idx;}

public final ConstantClass getEnclosingClass() {
ConstantClass c =
(ConstantClass)constant_pool.getConstant(classIndex,Constants.CONSTANT_Class);
return c;
}

public final ConstantNameAndType getEnclosingMethod() {
if (methodIndex == 0) return null;
ConstantNameAndType nat =
(ConstantNameAndType)constant_pool.getConstant(methodIndex,Constants.CONSTANT_NameAndType);
return nat;
}



public final void dump(DataOutputStream file) throws IOException {
super.dump(file);
@@ -39,13 +39,7 @@ public final class ExceptionTable extends Attribute {
private int[] exception_index_table; // constant pool


/**
* Initialize from another object. Note that both objects use the same
* references (shallow copy). Use copy() for a physical copy.
*/
public ExceptionTable(ExceptionTable c) {
this(c.getNameIndex(), c.getLength(), c.getExceptionIndexTable(), c.getConstantPool());
}



/**
@@ -107,33 +101,13 @@ public final void dump( DataOutputStream file ) throws IOException {
}


/**
* @return Array of indices into constant pool of thrown exceptions.
*/
public final int[] getExceptionIndexTable() {
return exception_index_table;
}



/**
* @return Length of exception table.
*/
public final int getNumberOfExceptions() {
return number_of_exceptions;
}



/**
* @return class names of thrown exceptions
*/
public final String[] getExceptionNames() {
String[] names = new String[number_of_exceptions];
for (int i = 0; i < number_of_exceptions; i++) {
names[i] = constant_pool.getConstantString(exception_index_table[i],
Constants.CONSTANT_Class).replace('/', '.');
}
return names;
}



/**
@@ -19,7 +19,6 @@
import java.io.DataInputStream;
import java.io.IOException;
import org.apache.tomcat.util.bcel.Constants;
import org.apache.tomcat.util.bcel.generic.Type;
import org.apache.tomcat.util.bcel.util.BCELComparator;

/**
@@ -48,13 +47,7 @@ public int hashCode( Object o ) {
};


/**
* Initialize from another object. Note that both objects use the same
* references (shallow copy). Use clone() for a physical copy.
*/
public Field(Field c) {
super(c);
}



/**
@@ -67,29 +60,10 @@ public Field(Field c) {
}


/**
* @param access_flags Access rights of field
* @param name_index Points to field name in constant pool
* @param signature_index Points to encoded signature
* @param attributes Collection of attributes
* @param constant_pool Array of constants
*/
public Field(int access_flags, int name_index, int signature_index, Attribute[] attributes,
ConstantPool constant_pool) {
super(access_flags, name_index, signature_index, attributes, constant_pool);
}



/**
* Called by objects that are traversing the nodes of the tree implicitely
* defined by the contents of a Java class. I.e., the hierarchy of methods,
* fields, attributes, etc. spawns a tree of objects.
*
* @param v Visitor object
*/
public void accept( Visitor v ) {
v.visitField(this);
}



/**
@@ -134,36 +108,16 @@ public final String toString() {
}


/**
* @return deep copy of this field
*/
public final Field copy( ConstantPool _constant_pool ) {
return (Field) copy_(_constant_pool);
}



/**
* @return type of field
*/
public Type getType() {
return Type.getReturnType(getSignature());
}



/**
* @return Comparison strategy object
*/
public static BCELComparator getComparator() {
return _cmp;
}



/**
* @param comparator Comparison strategy object
*/
public static void setComparator( BCELComparator comparator ) {
_cmp = comparator;
}



/**
@@ -17,13 +17,9 @@
package org.apache.tomcat.util.bcel.classfile;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.tomcat.util.bcel.Constants;
import org.apache.tomcat.util.bcel.classfile.Attribute;
import org.apache.tomcat.util.bcel.classfile.Signature;

/**
* Abstract super class for fields and methods.
@@ -37,7 +33,7 @@ public abstract class FieldOrMethod extends AccessFlags implements Cloneable, No
protected int signature_index; // Points to encoded signature
protected int attributes_count; // No. of attributes
protected Attribute[] attributes; // Collection of attributes
protected AnnotationEntry[] annotationEntries; // annotations defined on the field or method

protected ConstantPool constant_pool;

private String signatureAttributeString = null;
@@ -51,14 +47,7 @@ public abstract class FieldOrMethod extends AccessFlags implements Cloneable, No
}


/**
* Initialize from another object. Note that both objects use the same
* references (shallow copy). Use clone() for a physical copy.
*/
protected FieldOrMethod(FieldOrMethod c) {
this(c.getAccessFlags(), c.getNameIndex(), c.getSignatureIndex(), c.getAttributes(), c
.getConstantPool());
}



/**
@@ -96,29 +85,10 @@ protected FieldOrMethod(int access_flags, int name_index, int signature_index,
}


/**
* Dump object to file stream on binary format.
*
* @param file Output file stream
* @throws IOException
*/
public final void dump( DataOutputStream file ) throws IOException {
file.writeShort(access_flags);
file.writeShort(name_index);
file.writeShort(signature_index);
file.writeShort(attributes_count);
for (int i = 0; i < attributes_count; i++) {
attributes[i].dump(file);
}
}



/**
* @return Collection of object attributes.
*/
public final Attribute[] getAttributes() {
return attributes;
}



/**
@@ -130,52 +100,22 @@ public final void setAttributes( Attribute[] attributes ) {
}


/**
* @return Constant pool used by this object.
*/
public final ConstantPool getConstantPool() {
return constant_pool;
}



/**
* @param constant_pool Constant pool to be used for this object.
*/
public final void setConstantPool( ConstantPool constant_pool ) {
this.constant_pool = constant_pool;
}



/**
* @return Index in constant pool of object's name.
*/
public final int getNameIndex() {
return name_index;
}



/**
* @param name_index Index in constant pool of object's name.
*/
public final void setNameIndex( int name_index ) {
this.name_index = name_index;
}



/**
* @return Index in constant pool of field signature.
*/
public final int getSignatureIndex() {
return signature_index;
}



/**
* @param signature_index Index in constant pool of field signature.
*/
public final void setSignatureIndex( int signature_index ) {
this.signature_index = signature_index;
}



/**
@@ -198,93 +138,11 @@ public final String getSignature() {
}


/**
* @return deep copy of this field
*/
protected FieldOrMethod copy_( ConstantPool _constant_pool ) {
FieldOrMethod c = null;

try {
c = (FieldOrMethod)clone();
} catch(CloneNotSupportedException e) {}


c.constant_pool = constant_pool;
c.attributes = new Attribute[attributes_count];


for(int i=0; i < attributes_count; i++)
c.attributes[i] = attributes[i].copy(constant_pool);


return c;
}

/**
* Ensure we have unpacked any attributes that contain annotations.
* We don't remove these annotation attributes from the attributes list, they
* remain there.
*/
private void ensureAnnotationsUpToDate()
{
if (annotationsOutOfDate)
{
// Find attributes that contain annotation data
Attribute[] attrs = getAttributes();
List accumulatedAnnotations = new ArrayList();
for (int i = 0; i < attrs.length; i++)
{
Attribute attribute = attrs[i];
if (attribute instanceof Annotations)
{
Annotations annotations = (Annotations) attribute;
for (int j = 0; j < annotations.getAnnotationEntries().length; j++)
{
accumulatedAnnotations.add(annotations
.getAnnotationEntries()[j]);
}
}
}
annotationEntries = (AnnotationEntry[]) accumulatedAnnotations
.toArray(new AnnotationEntry[accumulatedAnnotations.size()]);
annotationsOutOfDate = false;
}
}

public AnnotationEntry[] getAnnotationEntries()
{
ensureAnnotationsUpToDate();
return annotationEntries;
}

public void addAnnotationEntry(AnnotationEntry a)
{
ensureAnnotationsUpToDate();
int len = annotationEntries.length;
AnnotationEntry[] newAnnotations = new AnnotationEntry[len + 1];
System.arraycopy(annotationEntries, 0, newAnnotations, 0, len);
newAnnotations[len] = a;
annotationEntries = newAnnotations;
}

/**
* Hunts for a signature attribute on the member and returns its contents. So where the 'regular' signature
* may be (Ljava/util/Vector;)V the signature attribute may in fact say 'Ljava/lang/Vector<Ljava/lang/String>;'
* Coded for performance - searches for the attribute only when requested - only searches for it once.
*/
public final String getGenericSignature()
{
if (!searchedForSignatureAttribute)
{
boolean found = false;
for (int i = 0; !found && i < attributes_count; i++)
{
if (attributes[i] instanceof Signature)
{
signatureAttributeString = ((Signature) attributes[i])
.getSignature();
found = true;
}
}
searchedForSignatureAttribute = true;
}
return signatureAttributeString;
}

}
@@ -40,13 +40,7 @@ public final class InnerClass implements Cloneable, Node, Serializable {
private int inner_access_flags;


/**
* Initialize from another object.
*/
public InnerClass(InnerClass c) {
this(c.getInnerClassIndex(), c.getOuterClassIndex(), c.getInnerNameIndex(), c
.getInnerAccessFlags());
}



/**
@@ -75,16 +69,7 @@ public InnerClass(int inner_class_index, int outer_class_index, int inner_name_i
}


/**
* Called by objects that are traversing the nodes of the tree implicitely
* defined by the contents of a Java class. I.e., the hierarchy of methods,
* fields, attributes, etc. spawns a tree of objects.
*
* @param v Visitor object
*/
public void accept( Visitor v ) {
v.visitInnerClass(this);
}



/**
@@ -101,68 +86,28 @@ public final void dump( DataOutputStream file ) throws IOException {
}


/**
* @return access flags of inner class.
*/
public final int getInnerAccessFlags() {
return inner_access_flags;
}



/**
* @return class index of inner class.
*/
public final int getInnerClassIndex() {
return inner_class_index;
}



/**
* @return name index of inner class.
*/
public final int getInnerNameIndex() {
return inner_name_index;
}



/**
* @return class index of outer class.
*/
public final int getOuterClassIndex() {
return outer_class_index;
}



/**
* @param inner_access_flags access flags for this inner class
*/
public final void setInnerAccessFlags( int inner_access_flags ) {
this.inner_access_flags = inner_access_flags;
}



/**
* @param inner_class_index index into the constant pool for this class
*/
public final void setInnerClassIndex( int inner_class_index ) {
this.inner_class_index = inner_class_index;
}



/**
* @param inner_name_index index into the constant pool for this class's name
*/
public final void setInnerNameIndex( int inner_name_index ) {
this.inner_name_index = inner_name_index;
}



/**
* @param outer_class_index index into the constant pool for the owning class
*/
public final void setOuterClassIndex( int outer_class_index ) {
this.outer_class_index = outer_class_index;
}



/**
@@ -37,13 +37,7 @@ public final class InnerClasses extends Attribute {
private int number_of_classes;


/**
* Initialize from another object. Note that both objects use the same
* references (shallow copy). Use clone() for a physical copy.
*/
public InnerClasses(InnerClasses c) {
this(c.getNameIndex(), c.getLength(), c.getInnerClasses(), c.getConstantPool());
}



/**
@@ -106,12 +100,7 @@ public final void dump( DataOutputStream file ) throws IOException {
}


/**
* @return array of inner class "records"
*/
public final InnerClass[] getInnerClasses() {
return inner_classes;
}



/**

Large diffs are not rendered by default.

@@ -36,12 +36,7 @@ public final class LineNumber implements Cloneable, Node, Serializable {
private int line_number; // number in source file


/**
* Initialize from another object.
*/
public LineNumber(LineNumber c) {
this(c.getStartPC(), c.getLineNumber());
}



/**
@@ -64,16 +59,7 @@ public LineNumber(int start_pc, int line_number) {
}


/**
* Called by objects that are traversing the nodes of the tree implicitely
* defined by the contents of a Java class. I.e., the hierarchy of methods,
* fields, attributes, etc. spawns a tree of objects.
*
* @param v Visitor object
*/
public void accept( Visitor v ) {
v.visitLineNumber(this);
}



/**
@@ -88,36 +74,16 @@ public final void dump( DataOutputStream file ) throws IOException {
}


/**
* @return Corresponding source line
*/
public final int getLineNumber() {
return line_number;
}



/**
* @return PC in code
*/
public final int getStartPC() {
return start_pc;
}



/**
* @param line_number the source line number
*/
public final void setLineNumber( int line_number ) {
this.line_number = line_number;
}



/**
* @param start_pc the pc for this line number
*/
public final void setStartPC( int start_pc ) {
this.start_pc = start_pc;
}



/**
@@ -37,13 +37,7 @@ public final class LineNumberTable extends Attribute {
private LineNumber[] line_number_table; // Table of line/numbers pairs


/*
* Initialize from another object. Note that both objects use the same
* references (shallow copy). Use copy() for a physical copy.
*/
public LineNumberTable(LineNumberTable c) {
this(c.getNameIndex(), c.getLength(), c.getLineNumberTable(), c.getConstantPool());
}



/*
@@ -105,12 +99,7 @@ public final void dump( DataOutputStream file ) throws IOException {
}


/**
* @return Array of (pc offset, line number) pairs.
*/
public final LineNumber[] getLineNumberTable() {
return line_number_table;
}



/**
@@ -145,47 +134,7 @@ public final String toString() {
}


/**
* Map byte code positions to source code lines.
*
* @param pos byte code offset
* @return corresponding line in source code
*/
public int getSourceLine( int pos ) {
int l = 0, r = line_number_table_length - 1;
if (r < 0) {
return -1;
}
int min_index = -1, min = -1;
/* Do a binary search since the array is ordered.
*/
do {
int i = (l + r) / 2;
int j = line_number_table[i].getStartPC();
if (j == pos) {
return line_number_table[i].getLineNumber();
} else if (pos < j) {
r = i - 1;
} else {
l = i + 1;
}
/* If exact match can't be found (which is the most common case)
* return the line number that corresponds to the greatest index less
* than pos.
*/
if (j < pos && j > min) {
min = j;
min_index = i;
}
} while (l <= r);
/* It's possible that we did not find any valid entry for the bytecode
* offset we were looking for.
*/
if (min_index < 0) {
return -1;
}
return line_number_table[min_index].getLineNumber();
}



/**
@@ -202,7 +151,5 @@ public Attribute copy( ConstantPool _constant_pool ) {
}


public final int getTableLength() {
return line_number_table_length;
}

}
@@ -43,14 +43,7 @@ public final class LocalVariable implements Constants, Cloneable, Node, Serializ
private ConstantPool constant_pool;


/**
* Initialize from another object. Note that both objects use the same
* references (shallow copy). Use copy() for a physical copy.
*/
public LocalVariable(LocalVariable c) {
this(c.getStartPC(), c.getLength(), c.getNameIndex(), c.getSignatureIndex(), c.getIndex(),
c.getConstantPool());
}



/**
@@ -83,16 +76,7 @@ public LocalVariable(int start_pc, int length, int name_index, int signature_ind
}


/**
* Called by objects that are traversing the nodes of the tree implicitely
* defined by the contents of a Java class. I.e., the hierarchy of methods,
* fields, attributes, etc. spawns a tree of objects.
*
* @param v Visitor object
*/
public void accept( Visitor v ) {
v.visitLocalVariable(this);
}



/**
@@ -110,20 +94,10 @@ public final void dump( DataOutputStream file ) throws IOException {
}


/**
* @return Constant pool used by this object.
*/
public final ConstantPool getConstantPool() {
return constant_pool;
}



/**
* @return Variable is valid within getStartPC() .. getStartPC()+getLength()
*/
public final int getLength() {
return length;
}



/**
@@ -136,12 +110,7 @@ public final String getName() {
}


/**
* @return Index in constant pool of variable name.
*/
public final int getNameIndex() {
return name_index;
}



/**
@@ -154,12 +123,7 @@ public final String getSignature() {
}


/**
* @return Index in constant pool of variable signature.
*/
public final int getSignatureIndex() {
return signature_index;
}



/**
@@ -170,60 +134,25 @@ public final int getIndex() {
}


/**
* @return Start of range where he variable is valid
*/
public final int getStartPC() {
return start_pc;
}



/**
* @param constant_pool Constant pool to be used for this object.
*/
public final void setConstantPool( ConstantPool constant_pool ) {
this.constant_pool = constant_pool;
}



/**
* @param length the length of this local variable
*/
public final void setLength( int length ) {
this.length = length;
}



/**
* @param name_index the index into the constant pool for the name of this variable
*/
public final void setNameIndex( int name_index ) {
this.name_index = name_index;
}



/**
* @param signature_index the index into the constant pool for the signature of this variable
*/
public final void setSignatureIndex( int signature_index ) {
this.signature_index = signature_index;
}



/**
* @param index the index in the local variable table of this variable
*/
public final void setIndex( int index ) {
this.index = index;
}



/**
* @param start_pc Specify range where the local variable is valid.
*/
public final void setStartPC( int start_pc ) {
this.start_pc = start_pc;
}



/**
@@ -36,13 +36,7 @@ public class LocalVariableTable extends Attribute {
private LocalVariable[] local_variable_table; // variables


/**
* Initialize from another object. Note that both objects use the same
* references (shallow copy). Use copy() for a physical copy.
*/
public LocalVariableTable(LocalVariableTable c) {
this(c.getNameIndex(), c.getLength(), c.getLocalVariableTable(), c.getConstantPool());
}



/**
@@ -104,12 +98,7 @@ public final void dump( DataOutputStream file ) throws IOException {
}


/**
* @return Array of local variables of method.
*/
public final LocalVariable[] getLocalVariableTable() {
return local_variable_table;
}



/**
@@ -132,26 +121,7 @@ public final LocalVariable getLocalVariable( int index ) {
}


/**
* @return matching variable using index when variable is used at supplied pc
*
* @param index the variable slot
* @param pc the current pc that this variable is alive
*
* @return the LocalVariable that matches or null if not found
*/
public final LocalVariable getLocalVariable( int index, int pc ) {
for (int i = 0; i < local_variable_table_length; i++) {
if (local_variable_table[i].getIndex() == index) {
int start_pc = local_variable_table[i].getStartPC();
int end_pc = start_pc + local_variable_table[i].getLength();
if ((pc >= start_pc) && (pc <= end_pc)) {
return local_variable_table[i];
}
}
}
return null;
}



public final void setLocalVariableTable( LocalVariable[] local_variable_table ) {
@@ -191,7 +161,5 @@ public Attribute copy( ConstantPool _constant_pool ) {
}


public final int getTableLength() {
return local_variable_table_length;
}

}
@@ -48,10 +48,7 @@ public class LocalVariableTypeTable extends Attribute {
private int local_variable_type_table_length; // Table of local
private LocalVariable[] local_variable_type_table; // variables

public LocalVariableTypeTable(LocalVariableTypeTable c) {
this(c.getNameIndex(), c.getLength(), c.getLocalVariableTypeTable(),
c.getConstantPool());
}


public LocalVariableTypeTable(int name_index, int length,
LocalVariable[] local_variable_table,
@@ -83,17 +80,9 @@ public final void dump(DataOutputStream file) throws IOException
local_variable_type_table[i].dump(file);
}

public final LocalVariable[] getLocalVariableTypeTable() {
return local_variable_type_table;
}


public final LocalVariable getLocalVariable(int index) {
for(int i=0; i < local_variable_type_table_length; i++)
if(local_variable_type_table[i].getIndex() == index)
return local_variable_type_table[i];

return null;
}


public final void setLocalVariableTable(LocalVariable[] local_variable_table)
{
@@ -131,5 +120,5 @@ public Attribute copy(ConstantPool constant_pool) {
return c;
}

public final int getTableLength() { return local_variable_type_table_length; }

}
@@ -19,7 +19,6 @@
import java.io.DataInputStream;
import java.io.IOException;
import org.apache.tomcat.util.bcel.Constants;
import org.apache.tomcat.util.bcel.generic.Type;
import org.apache.tomcat.util.bcel.util.BCELComparator;

/**
@@ -57,13 +56,7 @@ public Method() {
}


/**
* Initialize from another object. Note that both objects use the same
* references (shallow copy). Use clone() for a physical copy.
*/
public Method(Method c) {
super(c);
}



/**
@@ -78,29 +71,10 @@ public Method(Method c) {
}


/**
* @param access_flags Access rights of method
* @param name_index Points to field name in constant pool
* @param signature_index Points to encoded signature
* @param attributes Collection of attributes
* @param constant_pool Array of constants
*/
public Method(int access_flags, int name_index, int signature_index, Attribute[] attributes,
ConstantPool constant_pool) {
super(access_flags, name_index, signature_index, attributes, constant_pool);
}



/**
* Called by objects that are traversing the nodes of the tree implicitely
* defined by the contents of a Java class. I.e., the hierarchy of methods,
* fields, attributes, etc. spawns a tree of objects.
*
* @param v Visitor object
*/
public void accept( Visitor v ) {
v.visitMethod(this);
}



/**
@@ -142,16 +116,7 @@ public final LocalVariableTable getLocalVariableTable() {
}


/** @return LineNumberTable of code attribute if any, i.e. the call is forwarded
* to the Code atribute.
*/
public final LineNumberTable getLineNumberTable() {
Code code = getCode();
if (code == null) {
return null;
}
return code.getLineNumberTable();
}



/**
@@ -190,44 +155,19 @@ public final String toString() {
}


/**
* @return deep copy of this method
*/
public final Method copy( ConstantPool _constant_pool ) {
return (Method) copy_(_constant_pool);
}



/**
* @return return type of method
*/
public Type getReturnType() {
return Type.getReturnType(getSignature());
}



/**
* @return array of method argument types
*/
public Type[] getArgumentTypes() {
return Type.getArgumentTypes(getSignature());
}



/**
* @return Comparison strategy object
*/
public static BCELComparator getComparator() {
return _cmp;
}



/**
* @param comparator Comparison strategy object
*/
public static void setComparator( BCELComparator comparator ) {
_cmp = comparator;
}



/**
@@ -24,5 +24,5 @@
*/
public interface Node {

public void accept( Visitor obj );

}
@@ -35,14 +35,7 @@ public final class PMGClass extends Attribute {
private int pmg_class_index, pmg_index;


/**
* Initialize from another object. Note that both objects use the same
* references (shallow copy). Use clone() for a physical copy.
*/
public PMGClass(PMGClass c) {
this(c.getNameIndex(), c.getLength(), c.getPMGIndex(), c.getPMGClassIndex(), c
.getConstantPool());
}



/**
@@ -99,36 +92,16 @@ public final void dump( DataOutputStream file ) throws IOException {
}


/**
* @return Index in constant pool of source file name.
*/
public final int getPMGClassIndex() {
return pmg_class_index;
}



/**
* @param pmg_class_index
*/
public final void setPMGClassIndex( int pmg_class_index ) {
this.pmg_class_index = pmg_class_index;
}



/**
* @return Index in constant pool of source file name.
*/
public final int getPMGIndex() {
return pmg_index;
}



/**
* @param pmg_index
*/
public final void setPMGIndex( int pmg_index ) {
this.pmg_index = pmg_index;
}



/**
@@ -48,30 +48,11 @@ public class ParameterAnnotationEntry implements Node, Constants {
}


/**
* Called by objects that are traversing the nodes of the tree implicitely
* defined by the contents of a Java class. I.e., the hierarchy of methods,
* fields, attributes, etc. spawns a tree of objects.
*
* @param v Visitor object
*/
public void accept( Visitor v ) {
// v.visitParameterAnnotationEntry(this);
}



/**
* @return the number of annotation entries in this parameter annotation
*/
public final int getNumAnnotations() {
return annotation_table_length;
}



/**
* returns the array of annotation entries in this annotation
*/
public AnnotationEntry[] getAnnotationEntries() {
return annotation_table;
}

}
@@ -89,26 +89,11 @@ public final void setParameterAnnotationTable(
}


/**
* @return the parameter annotation entry table
*/
public final ParameterAnnotationEntry[] getParameterAnnotationTable() {
return parameter_annotation_table;
}



/**
* returns the array of parameter annotation entries in this parameter annotation
*/
public ParameterAnnotationEntry[] getParameterAnnotationEntries() {
return parameter_annotation_table;
}



/**
* @return the number of parameter annotation entries in this parameter annotation
*/
public final int getNumParameterAnnotation() {
return num_parameters;
}

}
@@ -36,13 +36,7 @@ public final class Signature extends Attribute {
private int signature_index;


/**
* Initialize from another object. Note that both objects use the same
* references (shallow copy). Use clone() for a physical copy.
*/
public Signature(Signature c) {
this(c.getNameIndex(), c.getLength(), c.getSignatureIndex(), c.getConstantPool());
}



/**
@@ -96,20 +90,10 @@ public final void dump( DataOutputStream file ) throws IOException {
}


/**
* @return Index in constant pool of source file name.
*/
public final int getSignatureIndex() {
return signature_index;
}



/**
* @param signature_index the index info the constant pool of this signature
*/
public final void setSignatureIndex( int signature_index ) {
this.signature_index = signature_index;
}



/**
@@ -129,130 +113,6 @@ private static final class MyByteArrayInputStream extends ByteArrayInputStream {
MyByteArrayInputStream(String data) {
super(data.getBytes());
}


final int mark() {
return pos;
}


final String getData() {
return new String(buf);
}


final void reset( int p ) {
pos = p;
}


final void unread() {
if (pos > 0) {
pos--;
}
}
}


private static boolean identStart( int ch ) {
return ch == 'T' || ch == 'L';
}


private static final void matchIdent( MyByteArrayInputStream in, StringBuffer buf ) {
int ch;
if ((ch = in.read()) == -1) {
throw new RuntimeException("Illegal signature: " + in.getData()
+ " no ident, reaching EOF");
}
//System.out.println("return from ident:" + (char)ch);
if (!identStart(ch)) {
StringBuffer buf2 = new StringBuffer();
int count = 1;
while (Character.isJavaIdentifierPart((char) ch)) {
buf2.append((char) ch);
count++;
ch = in.read();
}
if (ch == ':') { // Ok, formal parameter
in.skip("Ljava/lang/Object".length());
buf.append(buf2);
ch = in.read();
in.unread();
//System.out.println("so far:" + buf2 + ":next:" +(char)ch);
} else {
for (int i = 0; i < count; i++) {
in.unread();
}
}
return;
}
StringBuffer buf2 = new StringBuffer();
ch = in.read();
do {
buf2.append((char) ch);
ch = in.read();
//System.out.println("within ident:"+ (char)ch);
} while ((ch != -1) && (Character.isJavaIdentifierPart((char) ch) || (ch == '/')));
buf.append(buf2.toString().replace('/', '.'));
//System.out.println("regular return ident:"+ (char)ch + ":" + buf2);
if (ch != -1) {
in.unread();
}
}


private static final void matchGJIdent( MyByteArrayInputStream in, StringBuffer buf ) {
int ch;
matchIdent(in, buf);
ch = in.read();
if ((ch == '<') || ch == '(') { // Parameterized or method
//System.out.println("Enter <");
buf.append((char) ch);
matchGJIdent(in, buf);
while (((ch = in.read()) != '>') && (ch != ')')) { // List of parameters
if (ch == -1) {
throw new RuntimeException("Illegal signature: " + in.getData()
+ " reaching EOF");
}
//System.out.println("Still no >");
buf.append(", ");
in.unread();
matchGJIdent(in, buf); // Recursive call
}
//System.out.println("Exit >");
buf.append((char) ch);
} else {
in.unread();
}
ch = in.read();
if (identStart(ch)) {
in.unread();
matchGJIdent(in, buf);
} else if (ch == ')') {
in.unread();
return;
} else if (ch != ';') {
throw new RuntimeException("Illegal signature: " + in.getData() + " read " + (char) ch);
}
}


public static String translate( String s ) {
//System.out.println("Sig:" + s);
StringBuffer buf = new StringBuffer();
matchGJIdent(new MyByteArrayInputStream(s), buf);
return buf.toString();
}


public static final boolean isFormalParameterList( String s ) {
return s.startsWith("<") && (s.indexOf(':') > 0);
}


public static final boolean isActualParameterList( String s ) {
return s.startsWith("L") && s.endsWith(">;");
}


@@ -38,10 +38,7 @@ public int getIndex()
return index;
}

public void setIndex(int index)
{
this.index = index;
}


public String getValueString()
{
@@ -37,13 +37,7 @@ public final class SourceFile extends Attribute {
private int sourcefile_index;


/**
* Initialize from another object. Note that both objects use the same
* references (shallow copy). Use clone() for a physical copy.
*/
public SourceFile(SourceFile c) {
this(c.getNameIndex(), c.getLength(), c.getSourceFileIndex(), c.getConstantPool());
}



/**
@@ -103,20 +97,10 @@ public final void dump( DataOutputStream file ) throws IOException {
}


/**
* @return Index in constant pool of source file name.
*/
public final int getSourceFileIndex() {
return sourcefile_index;
}



/**
* @param sourcefile_index
*/
public final void setSourceFileIndex( int sourcefile_index ) {
this.sourcefile_index = sourcefile_index;
}



/**
@@ -88,12 +88,7 @@ public final void dump( DataOutputStream file ) throws IOException {
}


/**
* @return Array of stack map entries
*/
public final StackMapEntry[] getStackMap() {
return map;
}



/**
@@ -147,7 +142,5 @@ public void accept( Visitor v ) {
}


public final int getMapLength() {
return map_length;
}

}
@@ -121,54 +121,34 @@ public final String toString() {
}


public void setByteCodeOffset( int b ) {
byte_code_offset = b;
}



public int getByteCodeOffset() {
return byte_code_offset;
}



public void setNumberOfLocals( int n ) {
number_of_locals = n;
}



public int getNumberOfLocals() {
return number_of_locals;
}



public void setTypesOfLocals( StackMapType[] t ) {
types_of_locals = t;
}



public StackMapType[] getTypesOfLocals() {
return types_of_locals;
}



public void setNumberOfStackItems( int n ) {
number_of_stack_items = n;
}



public int getNumberOfStackItems() {
return number_of_stack_items;
}



public void setTypesOfStackItems( StackMapType[] t ) {
types_of_stack_items = t;
}



public StackMapType[] getTypesOfStackItems() {
return types_of_stack_items;
}



/**
@@ -183,30 +163,11 @@ public StackMapEntry copy() {
}


/**
* Called by objects that are traversing the nodes of the tree implicitely
* defined by the contents of a Java class. I.e., the hierarchy of methods,
* fields, attributes, etc. spawns a tree of objects.
*
* @param v Visitor object
*/
public void accept( Visitor v ) {
v.visitStackMapEntry(this);
}



/**
* @return Constant pool used by this object.
*/
public final ConstantPool getConstantPool() {
return constant_pool;
}



/**
* @param constant_pool Constant pool to be used for this object.
*/
public final void setConstantPool( ConstantPool constant_pool ) {
this.constant_pool = constant_pool;
}

}
@@ -88,12 +88,7 @@ public final void dump( DataOutputStream file ) throws IOException {
}


/**
* @return Array of stack map entries
*/
public final StackMapTableEntry[] getStackMapTable() {
return map;
}



/**
@@ -147,7 +142,5 @@ public void accept( Visitor v ) {
}


public final int getMapLength() {
return map_length;
}

}