svn commit: r386056 [4/28] - in /jakarta/bcel/trunk: examples/ examples/Mini/ src/java/org/apache/bcel/ src/java/org/apache/bcel/classfile/ src/java/org/apache/bcel/generic/ src/java/org/apache/bcel/util/ src/java/org/apache/bcel/verifier/ src/java/org...

[email protected]
Newsgroups gmane.comp.jakarta.bcel.devel
Message-ID <[email protected]>
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantDouble.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantDouble.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantDouble.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantDouble.java Wed Mar 15 03:31:56 2006
@@ -31,76 +31,89 @@
  * @see     Constant
  */
 public final class ConstantDouble extends Constant implements ConstantObject {
-  private double bytes;
 
-  /** 
-   * @param bytes Data
-   */
-  public ConstantDouble(double bytes) {    
-    super(Constants.CONSTANT_Double);
-    this.bytes = bytes;
-  }    
-
-  /**
-   * Initialize from another object.
-   */
-  public ConstantDouble(ConstantDouble c) {
-    this(c.getBytes());
-  }    
-
-  /** 
-   * Initialize instance from file data.
-   *
-   * @param file Input stream
-   * @throws IOException
-   */
-  ConstantDouble(DataInputStream file) throws IOException
-  {    
-    this(file.readDouble());
-  }    
-
-  /**
-   * 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.visitConstantDouble(this);
-  }    
-  /**
-   * Dump constant double to file stream in binary format.
-   *
-   * @param file Output file stream
-   * @throws IOException
-   */ 
-  public final void dump(DataOutputStream file) throws IOException
-  {
-    file.writeByte(tag);
-    file.writeDouble(bytes);
-  }    
-  /**
-   * @return data, i.e., 8 bytes.
-   */  
-  public final double getBytes() { return bytes; }    
-  /**
-   * @param bytes the raw bytes that represent the double value
-   */
-  public final void setBytes(double bytes) {
-    this.bytes = bytes;
-  }    
-  /**
-   * @return String representation.
-   */
-  public final String toString()
-  {
-    return super.toString() + "(bytes = " + bytes + ")";
-  }    
-
-  /** @return Double object
-   */
-  public Object getConstantValue(ConstantPool cp) {
-    return new Double(bytes);
-  }
+    private double bytes;
+
+
+    /** 
+     * @param bytes Data
+     */
+    public ConstantDouble(double bytes) {
+        super(Constants.CONSTANT_Double);
+        this.bytes = bytes;
+    }
+
+
+    /**
+     * Initialize from another object.
+     */
+    public ConstantDouble(ConstantDouble c) {
+        this(c.getBytes());
+    }
+
+
+    /** 
+     * Initialize instance from file data.
+     *
+     * @param file Input stream
+     * @throws IOException
+     */
+    ConstantDouble(DataInputStream file) throws IOException {
+        this(file.readDouble());
+    }
+
+
+    /**
+     * 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.visitConstantDouble(this);
+    }
+
+
+    /**
+     * Dump constant double to file stream in binary format.
+     *
+     * @param file Output file stream
+     * @throws IOException
+     */
+    public final void dump( DataOutputStream file ) throws IOException {
+        file.writeByte(tag);
+        file.writeDouble(bytes);
+    }
+
+
+    /**
+     * @return data, i.e., 8 bytes.
+     */
+    public final double getBytes() {
+        return bytes;
+    }
+
+
+    /**
+     * @param bytes the raw bytes that represent the double value
+     */
+    public final void setBytes( double bytes ) {
+        this.bytes = bytes;
+    }
+
+
+    /**
+     * @return String representation.
+     */
+    public final String toString() {
+        return super.toString() + "(bytes = " + bytes + ")";
+    }
+
+
+    /** @return Double object
+     */
+    public Object getConstantValue( ConstantPool cp ) {
+        return new Double(bytes);
+    }
 }

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantFieldref.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantFieldref.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantFieldref.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantFieldref.java Wed Mar 15 03:31:56 2006
@@ -27,41 +27,43 @@
  * @author  <A HREF="mailto:[email protected]">M. Dahm</A>
  */
 public final class ConstantFieldref extends ConstantCP {
-  /**
-   * Initialize from another object.
-   */
-  public ConstantFieldref(ConstantFieldref c) {
-    super(Constants.CONSTANT_Fieldref, c.getClassIndex(), c.getNameAndTypeIndex());
-  }
-
-  /**
-   * Initialize instance from file data.
-   *
-   * @param file input stream
-   * @throws IOException
-   */
-  ConstantFieldref(DataInputStream file) throws IOException
-  {
-    super(Constants.CONSTANT_Fieldref, file);
-  }
-
-  /**
-   * @param class_index Reference to the class containing the Field
-   * @param name_and_type_index and the Field signature
-   */
-  public ConstantFieldref(int class_index, 
-			   int name_and_type_index) {
-    super(Constants.CONSTANT_Fieldref, class_index, name_and_type_index);
-  }    
-
-  /**
-   * 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 Fields,
-   * fields, attributes, etc. spawns a tree of objects.
-   *
-   * @param v Visitor object
-   */
-  public void accept(Visitor v) {
-    v.visitConstantFieldref(this);
-  }    
+
+    /**
+     * Initialize from another object.
+     */
+    public ConstantFieldref(ConstantFieldref c) {
+        super(Constants.CONSTANT_Fieldref, c.getClassIndex(), c.getNameAndTypeIndex());
+    }
+
+
+    /**
+     * Initialize instance from file data.
+     *
+     * @param file input stream
+     * @throws IOException
+     */
+    ConstantFieldref(DataInputStream file) throws IOException {
+        super(Constants.CONSTANT_Fieldref, file);
+    }
+
+
+    /**
+     * @param class_index Reference to the class containing the Field
+     * @param name_and_type_index and the Field signature
+     */
+    public ConstantFieldref(int class_index, int name_and_type_index) {
+        super(Constants.CONSTANT_Fieldref, class_index, name_and_type_index);
+    }
+
+
+    /**
+     * 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 Fields,
+     * fields, attributes, etc. spawns a tree of objects.
+     *
+     * @param v Visitor object
+     */
+    public void accept( Visitor v ) {
+        v.visitConstantFieldref(this);
+    }
 }

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantFloat.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantFloat.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantFloat.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantFloat.java Wed Mar 15 03:31:56 2006
@@ -31,75 +31,90 @@
  * @see     Constant
  */
 public final class ConstantFloat extends Constant implements ConstantObject {
-  private float bytes;
 
-  /** 
-   * @param bytes Data
-   */
-  public ConstantFloat(float bytes)
-  {    
-    super(Constants.CONSTANT_Float);
-    this.bytes = 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());
-  }    
-  /** 
-   * Initialize instance from file data.
-   *
-   * @param file Input stream
-   * @throws IOException
-   */
-  ConstantFloat(DataInputStream file) throws IOException
-  {    
-    this(file.readFloat());
-  }    
-  /**
-   * 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.visitConstantFloat(this);
-  }    
-  /**
-   * Dump constant float to file stream in binary format.
-   *
-   * @param file Output file stream
-   * @throws IOException
-   */ 
-  public final void dump(DataOutputStream file) throws IOException
-  {
-    file.writeByte(tag);
-    file.writeFloat(bytes);
-  }    
-  /**
-   * @return data, i.e., 4 bytes.
-   */  
-  public final float getBytes() { return bytes; }    
-  /**
-   * @param bytes the raw bytes that represent this float
-   */
-  public final void setBytes(float bytes) {
-    this.bytes = bytes;
-  }
-
-  /**
-   * @return String representation.
-   */
-  public final String toString() {
-    return super.toString() + "(bytes = " + bytes + ")";
-  }    
-
-  /** @return Float object
-   */
-  public Object getConstantValue(ConstantPool cp) {
-    return new Float(bytes);
-  }
+    private float bytes;
+
+
+    /** 
+     * @param bytes Data
+     */
+    public ConstantFloat(float bytes) {
+        super(Constants.CONSTANT_Float);
+        this.bytes = 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());
+    }
+
+
+    /** 
+     * Initialize instance from file data.
+     *
+     * @param file Input stream
+     * @throws IOException
+     */
+    ConstantFloat(DataInputStream file) throws IOException {
+        this(file.readFloat());
+    }
+
+
+    /**
+     * 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.visitConstantFloat(this);
+    }
+
+
+    /**
+     * Dump constant float to file stream in binary format.
+     *
+     * @param file Output file stream
+     * @throws IOException
+     */
+    public final void dump( DataOutputStream file ) throws IOException {
+        file.writeByte(tag);
+        file.writeFloat(bytes);
+    }
+
+
+    /**
+     * @return data, i.e., 4 bytes.
+     */
+    public final float getBytes() {
+        return bytes;
+    }
+
+
+    /**
+     * @param bytes the raw bytes that represent this float
+     */
+    public final void setBytes( float bytes ) {
+        this.bytes = bytes;
+    }
+
+
+    /**
+     * @return String representation.
+     */
+    public final String toString() {
+        return super.toString() + "(bytes = " + bytes + ")";
+    }
+
+
+    /** @return Float object
+     */
+    public Object getConstantValue( ConstantPool cp ) {
+        return new Float(bytes);
+    }
 }

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantInteger.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantInteger.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantInteger.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantInteger.java Wed Mar 15 03:31:56 2006
@@ -31,80 +31,89 @@
  * @see     Constant
  */
 public final class ConstantInteger extends Constant implements ConstantObject {
-  private int bytes;
 
-  /** 
-   * @param bytes Data
-   */
-  public ConstantInteger(int bytes)
-  {    
-    super(Constants.CONSTANT_Integer);
-    this.bytes = bytes;
-  }
-
-  /**
-   * Initialize from another object.
-   */
-  public ConstantInteger(ConstantInteger c) {
-    this(c.getBytes());
-  }
-
-  /** 
-   * Initialize instance from file data.
-   *
-   * @param file Input stream
-   * @throws IOException
-   */
-  ConstantInteger(DataInputStream file) throws IOException
-  {    
-    this(file.readInt());
-  }
-
-  /**
-   * 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.visitConstantInteger(this);
-  }
-
-  /**
-   * Dump constant integer to file stream in binary format.
-   *
-   * @param file Output file stream
-   * @throws IOException
-   */ 
-  public final void dump(DataOutputStream file) throws IOException
-  {
-    file.writeByte(tag);
-    file.writeInt(bytes);
-  }
-
-  /**
-   * @return data, i.e., 4 bytes.
-   */  
-  public final int getBytes() { return bytes; }
-
-  /**
-   * @param bytes the raw bytes that represent this integer
-   */
-  public final void setBytes(int bytes) {
-    this.bytes = bytes;
-  }
-
-  /**
-   * @return String representation.
-   */
-  public final String toString() {
-    return super.toString() + "(bytes = " + bytes + ")";
-  }    
-
-  /** @return Integer object
-   */
-  public Object getConstantValue(ConstantPool cp) {
-    return new Integer(bytes);
-  }
+    private int bytes;
+
+
+    /** 
+     * @param bytes Data
+     */
+    public ConstantInteger(int bytes) {
+        super(Constants.CONSTANT_Integer);
+        this.bytes = bytes;
+    }
+
+
+    /**
+     * Initialize from another object.
+     */
+    public ConstantInteger(ConstantInteger c) {
+        this(c.getBytes());
+    }
+
+
+    /** 
+     * Initialize instance from file data.
+     *
+     * @param file Input stream
+     * @throws IOException
+     */
+    ConstantInteger(DataInputStream file) throws IOException {
+        this(file.readInt());
+    }
+
+
+    /**
+     * 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.visitConstantInteger(this);
+    }
+
+
+    /**
+     * Dump constant integer to file stream in binary format.
+     *
+     * @param file Output file stream
+     * @throws IOException
+     */
+    public final void dump( DataOutputStream file ) throws IOException {
+        file.writeByte(tag);
+        file.writeInt(bytes);
+    }
+
+
+    /**
+     * @return data, i.e., 4 bytes.
+     */
+    public final int getBytes() {
+        return bytes;
+    }
+
+
+    /**
+     * @param bytes the raw bytes that represent this integer
+     */
+    public final void setBytes( int bytes ) {
+        this.bytes = bytes;
+    }
+
+
+    /**
+     * @return String representation.
+     */
+    public final String toString() {
+        return super.toString() + "(bytes = " + bytes + ")";
+    }
+
+
+    /** @return Integer object
+     */
+    public Object getConstantValue( ConstantPool cp ) {
+        return new Integer(bytes);
+    }
 }

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantInterfaceMethodref.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantInterfaceMethodref.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantInterfaceMethodref.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantInterfaceMethodref.java Wed Mar 15 03:31:56 2006
@@ -27,41 +27,43 @@
  * @author  <A HREF="mailto:[email protected]">M. Dahm</A>
  */
 public final class ConstantInterfaceMethodref extends ConstantCP {
-  /**
-   * Initialize from another object.
-   */
-  public ConstantInterfaceMethodref(ConstantInterfaceMethodref c) {
-    super(Constants.CONSTANT_InterfaceMethodref, c.getClassIndex(), c.getNameAndTypeIndex());
-  }
-
-  /**
-   * Initialize instance from file data.
-   *
-   * @param file input stream
-   * @throws IOException
-   */
-  ConstantInterfaceMethodref(DataInputStream file) throws IOException
-  {
-    super(Constants.CONSTANT_InterfaceMethodref, file);
-  }
-
-  /**
-   * @param class_index Reference to the class containing the method
-   * @param name_and_type_index and the method signature
-   */
-  public ConstantInterfaceMethodref(int class_index, 
-				    int name_and_type_index) {
-    super(Constants.CONSTANT_InterfaceMethodref, class_index, name_and_type_index);
-  }    
-
-  /**
-   * 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.visitConstantInterfaceMethodref(this);
-  }    
+
+    /**
+     * Initialize from another object.
+     */
+    public ConstantInterfaceMethodref(ConstantInterfaceMethodref c) {
+        super(Constants.CONSTANT_InterfaceMethodref, c.getClassIndex(), c.getNameAndTypeIndex());
+    }
+
+
+    /**
+     * Initialize instance from file data.
+     *
+     * @param file input stream
+     * @throws IOException
+     */
+    ConstantInterfaceMethodref(DataInputStream file) throws IOException {
+        super(Constants.CONSTANT_InterfaceMethodref, file);
+    }
+
+
+    /**
+     * @param class_index Reference to the class containing the method
+     * @param name_and_type_index and the method signature
+     */
+    public ConstantInterfaceMethodref(int class_index, int name_and_type_index) {
+        super(Constants.CONSTANT_InterfaceMethodref, class_index, name_and_type_index);
+    }
+
+
+    /**
+     * 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.visitConstantInterfaceMethodref(this);
+    }
 }

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantLong.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantLong.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantLong.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantLong.java Wed Mar 15 03:31:56 2006
@@ -31,73 +31,89 @@
  * @see     Constant
  */
 public final class ConstantLong extends Constant implements ConstantObject {
-  private long bytes;
 
-  /** 
-   * @param bytes Data
-   */
-  public ConstantLong(long bytes)
-  {
-    super(Constants.CONSTANT_Long);
-    this.bytes = bytes;
-  }    
-  /**
-   * Initialize from another object.
-   */
-  public ConstantLong(ConstantLong c) {
-    this(c.getBytes());
-  }    
-  /** 
-   * Initialize instance from file data.
-   *
-   * @param file Input stream
-   * @throws IOException
-   */
-  ConstantLong(DataInputStream file) throws IOException
-  {    
-    this(file.readLong());
-  }    
-  /**
-   * 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.visitConstantLong(this);
-  }    
-  /**
-   * Dump constant long to file stream in binary format.
-   *
-   * @param file Output file stream
-   * @throws IOException
-   */ 
-  public final void dump(DataOutputStream file) throws IOException
-  {
-    file.writeByte(tag);
-    file.writeLong(bytes);
-  }    
-  /**
-   * @return data, i.e., 8 bytes.
-   */  
-  public final long getBytes() { return bytes; }    
-  /**
-   * @param bytes thr raw bytes that represent this long
-   */
-  public final void setBytes(long bytes) {
-    this.bytes = bytes;
-  }    
-  /**
-   * @return String representation.
-   */
-  public final String toString() {
-    return super.toString() + "(bytes = " + bytes + ")";
-  }    
-
-  /** @return Long object
-   */
-  public Object getConstantValue(ConstantPool cp) {
-    return new Long(bytes);
-  }
+    private long bytes;
+
+
+    /** 
+     * @param bytes Data
+     */
+    public ConstantLong(long bytes) {
+        super(Constants.CONSTANT_Long);
+        this.bytes = bytes;
+    }
+
+
+    /**
+     * Initialize from another object.
+     */
+    public ConstantLong(ConstantLong c) {
+        this(c.getBytes());
+    }
+
+
+    /** 
+     * Initialize instance from file data.
+     *
+     * @param file Input stream
+     * @throws IOException
+     */
+    ConstantLong(DataInputStream file) throws IOException {
+        this(file.readLong());
+    }
+
+
+    /**
+     * 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.visitConstantLong(this);
+    }
+
+
+    /**
+     * Dump constant long to file stream in binary format.
+     *
+     * @param file Output file stream
+     * @throws IOException
+     */
+    public final void dump( DataOutputStream file ) throws IOException {
+        file.writeByte(tag);
+        file.writeLong(bytes);
+    }
+
+
+    /**
+     * @return data, i.e., 8 bytes.
+     */
+    public final long getBytes() {
+        return bytes;
+    }
+
+
+    /**
+     * @param bytes thr raw bytes that represent this long
+     */
+    public final void setBytes( long bytes ) {
+        this.bytes = bytes;
+    }
+
+
+    /**
+     * @return String representation.
+     */
+    public final String toString() {
+        return super.toString() + "(bytes = " + bytes + ")";
+    }
+
+
+    /** @return Long object
+     */
+    public Object getConstantValue( ConstantPool cp ) {
+        return new Long(bytes);
+    }
 }

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantMethodref.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantMethodref.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantMethodref.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantMethodref.java Wed Mar 15 03:31:56 2006
@@ -27,41 +27,43 @@
  * @author  <A HREF="mailto:[email protected]">M. Dahm</A>
  */
 public final class ConstantMethodref extends ConstantCP {
-  /**
-   * Initialize from another object.
-   */
-  public ConstantMethodref(ConstantMethodref c) {
-    super(Constants.CONSTANT_Methodref, c.getClassIndex(), c.getNameAndTypeIndex());
-  }
-
-  /**
-   * Initialize instance from file data.
-   *
-   * @param file input stream
-   * @throws IOException
-   */
-  ConstantMethodref(DataInputStream file) throws IOException
-  {
-    super(Constants.CONSTANT_Methodref, file);
-  }
-
-  /**
-   * @param class_index Reference to the class containing the method
-   * @param name_and_type_index and the method signature
-   */
-  public ConstantMethodref(int class_index, 
-			   int name_and_type_index) {
-    super(Constants.CONSTANT_Methodref, class_index, name_and_type_index);
-  }    
-
-  /**
-   * 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.visitConstantMethodref(this);
-  }    
+
+    /**
+     * Initialize from another object.
+     */
+    public ConstantMethodref(ConstantMethodref c) {
+        super(Constants.CONSTANT_Methodref, c.getClassIndex(), c.getNameAndTypeIndex());
+    }
+
+
+    /**
+     * Initialize instance from file data.
+     *
+     * @param file input stream
+     * @throws IOException
+     */
+    ConstantMethodref(DataInputStream file) throws IOException {
+        super(Constants.CONSTANT_Methodref, file);
+    }
+
+
+    /**
+     * @param class_index Reference to the class containing the method
+     * @param name_and_type_index and the method signature
+     */
+    public ConstantMethodref(int class_index, int name_and_type_index) {
+        super(Constants.CONSTANT_Methodref, class_index, name_and_type_index);
+    }
+
+
+    /**
+     * 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.visitConstantMethodref(this);
+    }
 }

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantNameAndType.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantNameAndType.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantNameAndType.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantNameAndType.java Wed Mar 15 03:31:56 2006
@@ -32,104 +32,117 @@
  * @see     Constant
  */
 public final class ConstantNameAndType extends Constant {
-  private int name_index;      // Name of field/method
-  private int signature_index; // and its signature.
 
-  /**
-   * Initialize from another object.
-   */
-  public ConstantNameAndType(ConstantNameAndType c) {
-    this(c.getNameIndex(), c.getSignatureIndex());
-  }
- 
-  /**
-   * Initialize instance from file data.
-   *
-   * @param file Input stream
-   * @throws IOException
-   */
-  ConstantNameAndType(DataInputStream file) throws IOException
-  {    
-    this(file.readUnsignedShort(), file.readUnsignedShort());
-  }
-
-  /**
-   * @param name_index Name of field/method
-   * @param signature_index and its signature
-   */
-  public ConstantNameAndType(int name_index,
-			     int signature_index)
-  {
-    super(Constants.CONSTANT_NameAndType);
-    this.name_index      = name_index;
-    this.signature_index = signature_index;
-  }
-
-  /**
-   * 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.visitConstantNameAndType(this);
-  }
-
-  /**
-   * Dump name and signature index to file stream in binary format.
-   *
-   * @param file Output file stream
-   * @throws IOException
-   */ 
-  public final void dump(DataOutputStream file) throws IOException
-  {
-    file.writeByte(tag);
-    file.writeShort(name_index);
-    file.writeShort(signature_index);
-  }
-
-  /**
-   * @return Name index in constant pool of field/method name.
-   */  
-  public final int getNameIndex()      { return name_index; }
-
-  /** @return name
-   */
-  public final String getName(ConstantPool cp) {
-    return cp.constantToString(getNameIndex(), Constants.CONSTANT_Utf8);
-  }
-
-  /**
-   * @return Index in constant pool of field/method signature.
-   */  
-  public final int getSignatureIndex() { return signature_index; }
-
-  /** @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;
-  }
-
-  /**
-   * @return String representation
-   */
-  public final String toString() {
-    return super.toString() + "(name_index = " + name_index + 
-      ", signature_index = " + signature_index + ")";
-  }    
+    private int name_index; // Name of field/method
+    private int signature_index; // and its signature.
+
+
+    /**
+     * Initialize from another object.
+     */
+    public ConstantNameAndType(ConstantNameAndType c) {
+        this(c.getNameIndex(), c.getSignatureIndex());
+    }
+
+
+    /**
+     * Initialize instance from file data.
+     *
+     * @param file Input stream
+     * @throws IOException
+     */
+    ConstantNameAndType(DataInputStream file) throws IOException {
+        this(file.readUnsignedShort(), file.readUnsignedShort());
+    }
+
+
+    /**
+     * @param name_index Name of field/method
+     * @param signature_index and its signature
+     */
+    public ConstantNameAndType(int name_index, int signature_index) {
+        super(Constants.CONSTANT_NameAndType);
+        this.name_index = name_index;
+        this.signature_index = signature_index;
+    }
+
+
+    /**
+     * 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.visitConstantNameAndType(this);
+    }
+
+
+    /**
+     * Dump name and signature index to file stream in binary format.
+     *
+     * @param file Output file stream
+     * @throws IOException
+     */
+    public final void dump( DataOutputStream file ) throws IOException {
+        file.writeByte(tag);
+        file.writeShort(name_index);
+        file.writeShort(signature_index);
+    }
+
+
+    /**
+     * @return Name index in constant pool of field/method name.
+     */
+    public final int getNameIndex() {
+        return name_index;
+    }
+
+
+    /** @return name
+     */
+    public final String getName( ConstantPool cp ) {
+        return cp.constantToString(getNameIndex(), Constants.CONSTANT_Utf8);
+    }
+
+
+    /**
+     * @return Index in constant pool of field/method signature.
+     */
+    public final int getSignatureIndex() {
+        return signature_index;
+    }
+
+
+    /** @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;
+    }
+
+
+    /**
+     * @return String representation
+     */
+    public final String toString() {
+        return super.toString() + "(name_index = " + name_index + ", signature_index = "
+                + signature_index + ")";
+    }
 }

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantObject.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantObject.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantObject.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantObject.java Wed Mar 15 03:31:56 2006
@@ -25,7 +25,8 @@
  * @see     Constant
  */
 public interface ConstantObject {
-  /** @return object representing the constant, e.g., Long for ConstantLong
-   */
-  public abstract Object getConstantValue(ConstantPool cp);
+
+    /** @return object representing the constant, e.g., Long for ConstantLong
+     */
+    public abstract Object getConstantValue( ConstantPool cp );
 }

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantPool.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantPool.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantPool.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantPool.java Wed Mar 15 03:31:56 2006
@@ -36,302 +36,318 @@
  * @author <A HREF="mailto:[email protected]">M. Dahm</A>
  */
 public class ConstantPool implements Cloneable, Node, Serializable {
-  private int        constant_pool_count;
-  private Constant[] constant_pool;
 
-  /**
-   * @param constant_pool Array of constants
-   */
-  public ConstantPool(Constant[] constant_pool)
-  {
-    setConstantPool(constant_pool);
-  }
-
-  /**
-   * Read constants from given file stream.
-   *
-   * @param file Input stream
-   * @throws IOException
-   * @throws ClassFormatException
-   */
-  ConstantPool(DataInputStream file) throws IOException, ClassFormatException
-  {
-    byte tag;
-
-    constant_pool_count = file.readUnsignedShort();
-    constant_pool       = new Constant[constant_pool_count];
-
-    /* constant_pool[0] is unused by the compiler and may be used freely
-     * by the implementation.
-     */
-    for(int i=1; i < constant_pool_count; i++) {
-      constant_pool[i] = Constant.readConstant(file);
-	  
-      /* Quote from the JVM specification:
-       * "All eight byte constants take up two spots in the constant pool.
-       * If this is the n'th byte in the constant pool, then the next item
-       * will be numbered n+2"
-       * 
-       * Thus we have to increment the index counter.
-       */
-      tag = constant_pool[i].getTag();
-      if((tag == Constants.CONSTANT_Double) || (tag == Constants.CONSTANT_Long))
-	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.visitConstantPool(this);
-  }    
-
-  /**
-   * Resolve constant to a string representation.
-   *
-   * @param  c Constant to be printed
-   * @return String representation
-   */
-  public String constantToString(Constant c)
-       throws ClassFormatException  
-  {
-    String   str;
-    int      i;
-    byte     tag = c.getTag();
-
-    switch(tag) {
-    case Constants.CONSTANT_Class: 
-      i   = ((ConstantClass)c).getNameIndex();
-      c   = getConstant(i, Constants.CONSTANT_Utf8);
-      str = Utility.compactClassName(((ConstantUtf8)c).getBytes(), false);
-      break;
-
-    case Constants.CONSTANT_String:
-      i   = ((ConstantString)c).getStringIndex();
-      c   = getConstant(i, Constants.CONSTANT_Utf8);
-      str = "\"" + escape(((ConstantUtf8)c).getBytes()) + "\"";
-      break;
-
-    case Constants.CONSTANT_Utf8:    str = ((ConstantUtf8)c).getBytes();         break;
-    case Constants.CONSTANT_Double:  str = "" + ((ConstantDouble)c).getBytes();  break;
-    case Constants.CONSTANT_Float:   str = "" + ((ConstantFloat)c).getBytes();   break;
-    case Constants.CONSTANT_Long:    str = "" + ((ConstantLong)c).getBytes();    break;
-    case Constants.CONSTANT_Integer: str = "" + ((ConstantInteger)c).getBytes(); break;
-
-    case Constants.CONSTANT_NameAndType:
-      str = (constantToString(((ConstantNameAndType)c).getNameIndex(),
-			      Constants.CONSTANT_Utf8) + " " +
-	     constantToString(((ConstantNameAndType)c).getSignatureIndex(),
-			      Constants.CONSTANT_Utf8));
-      break;
-
-    case Constants.CONSTANT_InterfaceMethodref: case Constants.CONSTANT_Methodref:
-    case Constants.CONSTANT_Fieldref:
-      str = (constantToString(((ConstantCP)c).getClassIndex(),
-			      Constants.CONSTANT_Class) + "." + 
-	     constantToString(((ConstantCP)c).getNameAndTypeIndex(),
-			      Constants.CONSTANT_NameAndType));	     
-      break;
-
-    default: // Never reached
-      throw new RuntimeException("Unknown constant type " + tag);
-    }
-	
-    return str;
-  }    
-
-  private static final String escape(String str) {
-    int          len = str.length();
-    StringBuffer buf = new StringBuffer(len + 5);
-    char[]       ch  = str.toCharArray();
-
-    for(int i=0; i < len; i++) {
-      switch(ch[i]) {
-      case '\n' : buf.append("\\n"); break;
-      case '\r' : buf.append("\\r"); break;
-      case '\t' : buf.append("\\t"); break;
-      case '\b' : buf.append("\\b"); break;
-      case '"'  : buf.append("\\\""); break;
-      default: buf.append(ch[i]);
-      }
-    }
-
-    return buf.toString();
-  }
-
-
-  /**
-   * Retrieve constant at `index' from constant pool and resolve it to
-   * a string representation.
-   *
-   * @param  index of constant in constant pool
-   * @param  tag expected type
-   * @return String representation
-   */
-  public String constantToString(int index, byte tag) 
-       throws ClassFormatException
-  {
-    Constant c = getConstant(index, tag);
-    return constantToString(c);
-  }
-
-  /** 
-   * 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);
-  }
-
-  /**
-   * Get constant from constant pool.
-   *
-   * @param  index Index in constant pool
-   * @return Constant value
-   * @see    Constant
-   */
-  public Constant getConstant(int index) {
-    if (index >= constant_pool.length || index < 0)
-      throw new ClassFormatException("Invalid constant pool reference: " +
-				 index + ". Constant pool size is: " +
-				 constant_pool.length);
-    return constant_pool[index];
-  }
-
-  /**
-   * Get constant from constant pool and check whether it has the
-   * expected type.
-   *
-   * @param  index Index in constant pool
-   * @param  tag Tag of expected constant, i.e., its type
-   * @return Constant value
-   * @see    Constant
-   * @throws  ClassFormatException
-   */
-  public Constant getConstant(int index, byte tag)
-       throws ClassFormatException
-  {
-    Constant c;
-
-    c = getConstant(index);
-
-    if(c == null)
-      throw new ClassFormatException("Constant pool at index " + index + " is null.");
-
-    if(c.getTag() != tag)
-      throw new ClassFormatException("Expected class `" + Constants.CONSTANT_NAMES[tag] + 
-				 "' at index " + index + " and got " + c);
-    
-    return c;
-  }
-
-  /**
-   * @return Array of constants.
-   * @see    Constant
-   */
-  public Constant[] getConstantPool() { return constant_pool;  }    
-  /**
-   * Get string from constant pool and bypass the indirection of 
-   * `ConstantClass' and `ConstantString' objects. I.e. these classes have
-   * an index field that points to another entry of the constant pool of
-   * type `ConstantUtf8' which contains the real data.
-   *
-   * @param  index Index in constant pool
-   * @param  tag Tag of expected constant, either ConstantClass or ConstantString
-   * @return Contents of string reference
-   * @see    ConstantClass
-   * @see    ConstantString
-   * @throws  ClassFormatException
-   */
-  public String getConstantString(int index, byte tag) 
-       throws ClassFormatException
-  {
-    Constant c;
-    int    i;
-
-    c = getConstant(index, tag);
-
-    /* This switch() is not that elegant, since the two classes have the
-     * same contents, they just differ in the name of the index
-     * field variable.
-     * But we want to stick to the JVM naming conventions closely though
-     * we could have solved these more elegantly by using the same
-     * variable name or by subclassing.
-     */
-    switch(tag) {
-    case Constants.CONSTANT_Class:  i = ((ConstantClass)c).getNameIndex();    break;
-    case Constants.CONSTANT_String: i = ((ConstantString)c).getStringIndex(); break;
-    default:
-      throw new RuntimeException("getConstantString called with illegal tag " + tag);
-    }
-
-    // Finally get the string from the constant pool
-    c = getConstant(i, Constants.CONSTANT_Utf8);
-    return ((ConstantUtf8)c).getBytes();
-  }    
-  /**
-   * @return Length of constant pool.
-   */
-  public int getLength()
-  {
-    return constant_pool_count;
-  }    
-
-  /**
-   * @param constant Constant to set
-   */
-  public void setConstant(int index, Constant constant) {
-    constant_pool[index] = constant;
-  }    
-
-  /**
-   * @param constant_pool
-   */
-  public void setConstantPool(Constant[] constant_pool) {
-    this.constant_pool = constant_pool;
-    constant_pool_count = (constant_pool == null)? 0 : constant_pool.length;
-  }    
-  /**
-   * @return String representation.
-   */
-  public String toString() {
-    StringBuffer buf = new StringBuffer();
-
-    for(int i=1; i < constant_pool_count; i++)
-      buf.append(i).append(")").append(constant_pool[i]).append("\n");
-
-    return buf.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) {}
+    private int constant_pool_count;
+    private Constant[] constant_pool;
 
 
-    return c;
-  }
+    /**
+     * @param constant_pool Array of constants
+     */
+    public ConstantPool(Constant[] constant_pool) {
+        setConstantPool(constant_pool);
+    }
+
+
+    /**
+     * Read constants from given file stream.
+     *
+     * @param file Input stream
+     * @throws IOException
+     * @throws ClassFormatException
+     */
+    ConstantPool(DataInputStream file) throws IOException, ClassFormatException {
+        byte tag;
+        constant_pool_count = file.readUnsignedShort();
+        constant_pool = new Constant[constant_pool_count];
+        /* constant_pool[0] is unused by the compiler and may be used freely
+         * by the implementation.
+         */
+        for (int i = 1; i < constant_pool_count; i++) {
+            constant_pool[i] = Constant.readConstant(file);
+            /* Quote from the JVM specification:
+             * "All eight byte constants take up two spots in the constant pool.
+             * If this is the n'th byte in the constant pool, then the next item
+             * will be numbered n+2"
+             * 
+             * Thus we have to increment the index counter.
+             */
+            tag = constant_pool[i].getTag();
+            if ((tag == Constants.CONSTANT_Double) || (tag == Constants.CONSTANT_Long)) {
+                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.visitConstantPool(this);
+    }
+
+
+    /**
+     * Resolve constant to a string representation.
+     *
+     * @param  c Constant to be printed
+     * @return String representation
+     */
+    public String constantToString( Constant c ) throws ClassFormatException {
+        String str;
+        int i;
+        byte tag = c.getTag();
+        switch (tag) {
+            case Constants.CONSTANT_Class:
+                i = ((ConstantClass) c).getNameIndex();
+                c = getConstant(i, Constants.CONSTANT_Utf8);
+                str = Utility.compactClassName(((ConstantUtf8) c).getBytes(), false);
+                break;
+            case Constants.CONSTANT_String:
+                i = ((ConstantString) c).getStringIndex();
+                c = getConstant(i, Constants.CONSTANT_Utf8);
+                str = "\"" + escape(((ConstantUtf8) c).getBytes()) + "\"";
+                break;
+            case Constants.CONSTANT_Utf8:
+                str = ((ConstantUtf8) c).getBytes();
+                break;
+            case Constants.CONSTANT_Double:
+                str = "" + ((ConstantDouble) c).getBytes();
+                break;
+            case Constants.CONSTANT_Float:
+                str = "" + ((ConstantFloat) c).getBytes();
+                break;
+            case Constants.CONSTANT_Long:
+                str = "" + ((ConstantLong) c).getBytes();
+                break;
+            case Constants.CONSTANT_Integer:
+                str = "" + ((ConstantInteger) c).getBytes();
+                break;
+            case Constants.CONSTANT_NameAndType:
+                str = (constantToString(((ConstantNameAndType) c).getNameIndex(),
+                        Constants.CONSTANT_Utf8)
+                        + " " + constantToString(((ConstantNameAndType) c).getSignatureIndex(),
+                        Constants.CONSTANT_Utf8));
+                break;
+            case Constants.CONSTANT_InterfaceMethodref:
+            case Constants.CONSTANT_Methodref:
+            case Constants.CONSTANT_Fieldref:
+                str = (constantToString(((ConstantCP) c).getClassIndex(), Constants.CONSTANT_Class)
+                        + "." + constantToString(((ConstantCP) c).getNameAndTypeIndex(),
+                        Constants.CONSTANT_NameAndType));
+                break;
+            default: // Never reached
+                throw new RuntimeException("Unknown constant type " + tag);
+        }
+        return str;
+    }
+
+
+    private static final String escape( String str ) {
+        int len = str.length();
+        StringBuffer buf = new StringBuffer(len + 5);
+        char[] ch = str.toCharArray();
+        for (int i = 0; i < len; i++) {
+            switch (ch[i]) {
+                case '\n':
+                    buf.append("\\n");
+                    break;
+                case '\r':
+                    buf.append("\\r");
+                    break;
+                case '\t':
+                    buf.append("\\t");
+                    break;
+                case '\b':
+                    buf.append("\\b");
+                    break;
+                case '"':
+                    buf.append("\\\"");
+                    break;
+                default:
+                    buf.append(ch[i]);
+            }
+        }
+        return buf.toString();
+    }
+
+
+    /**
+     * Retrieve constant at `index' from constant pool and resolve it to
+     * a string representation.
+     *
+     * @param  index of constant in constant pool
+     * @param  tag expected type
+     * @return String representation
+     */
+    public String constantToString( int index, byte tag ) throws ClassFormatException {
+        Constant c = getConstant(index, tag);
+        return constantToString(c);
+    }
+
+
+    /** 
+     * 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);
+            }
+        }
+    }
+
+
+    /**
+     * Get constant from constant pool.
+     *
+     * @param  index Index in constant pool
+     * @return Constant value
+     * @see    Constant
+     */
+    public Constant getConstant( int index ) {
+        if (index >= constant_pool.length || index < 0) {
+            throw new ClassFormatException("Invalid constant pool reference: " + index
+                    + ". Constant pool size is: " + constant_pool.length);
+        }
+        return constant_pool[index];
+    }
+
+
+    /**
+     * Get constant from constant pool and check whether it has the
+     * expected type.
+     *
+     * @param  index Index in constant pool
+     * @param  tag Tag of expected constant, i.e., its type
+     * @return Constant value
+     * @see    Constant
+     * @throws  ClassFormatException
+     */
+    public Constant getConstant( int index, byte tag ) throws ClassFormatException {
+        Constant c;
+        c = getConstant(index);
+        if (c == null) {
+            throw new ClassFormatException("Constant pool at index " + index + " is null.");
+        }
+        if (c.getTag() != tag) {
+            throw new ClassFormatException("Expected class `" + Constants.CONSTANT_NAMES[tag]
+                    + "' at index " + index + " and got " + c);
+        }
+        return c;
+    }
+
+
+    /**
+     * @return Array of constants.
+     * @see    Constant
+     */
+    public Constant[] getConstantPool() {
+        return constant_pool;
+    }
+
+
+    /**
+     * Get string from constant pool and bypass the indirection of 
+     * `ConstantClass' and `ConstantString' objects. I.e. these classes have
+     * an index field that points to another entry of the constant pool of
+     * type `ConstantUtf8' which contains the real data.
+     *
+     * @param  index Index in constant pool
+     * @param  tag Tag of expected constant, either ConstantClass or ConstantString
+     * @return Contents of string reference
+     * @see    ConstantClass
+     * @see    ConstantString
+     * @throws  ClassFormatException
+     */
+    public String getConstantString( int index, byte tag ) throws ClassFormatException {
+        Constant c;
+        int i;
+        c = getConstant(index, tag);
+        /* This switch() is not that elegant, since the two classes have the
+         * same contents, they just differ in the name of the index
+         * field variable.
+         * But we want to stick to the JVM naming conventions closely though
+         * we could have solved these more elegantly by using the same
+         * variable name or by subclassing.
+         */
+        switch (tag) {
+            case Constants.CONSTANT_Class:
+                i = ((ConstantClass) c).getNameIndex();
+                break;
+            case Constants.CONSTANT_String:
+                i = ((ConstantString) c).getStringIndex();
+                break;
+            default:
+                throw new RuntimeException("getConstantString called with illegal tag " + tag);
+        }
+        // Finally get the string from the constant pool
+        c = getConstant(i, Constants.CONSTANT_Utf8);
+        return ((ConstantUtf8) c).getBytes();
+    }
+
+
+    /**
+     * @return Length of constant pool.
+     */
+    public int getLength() {
+        return constant_pool_count;
+    }
+
+
+    /**
+     * @param constant Constant to set
+     */
+    public void setConstant( int index, Constant constant ) {
+        constant_pool[index] = constant;
+    }
+
+
+    /**
+     * @param constant_pool
+     */
+    public void setConstantPool( Constant[] constant_pool ) {
+        this.constant_pool = constant_pool;
+        constant_pool_count = (constant_pool == null) ? 0 : constant_pool.length;
+    }
+
+
+    /**
+     * @return String representation.
+     */
+    public String toString() {
+        StringBuffer buf = new StringBuffer();
+        for (int i = 1; i < constant_pool_count; i++) {
+            buf.append(i).append(")").append(constant_pool[i]).append("\n");
+        }
+        return buf.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;
+    }
 }

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantString.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantString.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantString.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantString.java Wed Mar 15 03:31:56 2006
@@ -31,82 +31,97 @@
  * @see     Constant
  */
 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());
-  }    
-  /** 
-   * Initialize instance from file data.
-   *
-   * @param file Input stream
-   * @throws IOException
-   */
-  ConstantString(DataInputStream file) throws IOException
-  {    
-    this(file.readUnsignedShort());
-  }    
-  /**
-   * @param string_index Index of Constant_Utf8 in constant pool
-   */
-  public ConstantString(int string_index)
-  {    
-    super(Constants.CONSTANT_String);
-    this.string_index = string_index;
-  }    
-  /**
-   * 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.visitConstantString(this);
-  }    
-  /**
-   * Dump constant field reference to file stream in binary format.
-   *
-   * @param file Output file stream
-   * @throws IOException
-   */ 
-  public final void dump(DataOutputStream file) throws IOException
-  {
-    file.writeByte(tag);
-    file.writeShort(string_index);
-  }    
-  /**
-   * @return Index in constant pool of the string (ConstantUtf8).
-   */  
-  public final int getStringIndex() { return string_index; }    
-  
-  /**
-   * @param string_index the index into the constant of the string value
-   */
-  public final void setStringIndex(int string_index) {
-    this.string_index = string_index;
-  }    
-  /**
-   * @return String representation.
-   */
-  public final String toString()
-  {
-    return super.toString() + "(string_index = " + string_index + ")";
-  }    
-
-  /** @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);
-  }
+    private int string_index; // Identical to ConstantClass except for this name
+
+
+    /**
+     * Initialize from another object.
+     */
+    public ConstantString(ConstantString c) {
+        this(c.getStringIndex());
+    }
+
+
+    /** 
+     * Initialize instance from file data.
+     *
+     * @param file Input stream
+     * @throws IOException
+     */
+    ConstantString(DataInputStream file) throws IOException {
+        this(file.readUnsignedShort());
+    }
+
+
+    /**
+     * @param string_index Index of Constant_Utf8 in constant pool
+     */
+    public ConstantString(int string_index) {
+        super(Constants.CONSTANT_String);
+        this.string_index = string_index;
+    }
+
+
+    /**
+     * 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.visitConstantString(this);
+    }
+
+
+    /**
+     * Dump constant field reference to file stream in binary format.
+     *
+     * @param file Output file stream
+     * @throws IOException
+     */
+    public final void dump( DataOutputStream file ) throws IOException {
+        file.writeByte(tag);
+        file.writeShort(string_index);
+    }
+
+
+    /**
+     * @return Index in constant pool of the string (ConstantUtf8).
+     */
+    public final int getStringIndex() {
+        return string_index;
+    }
+
+
+    /**
+     * @param string_index the index into the constant of the string value
+     */
+    public final void setStringIndex( int string_index ) {
+        this.string_index = string_index;
+    }
+
+
+    /**
+     * @return String representation.
+     */
+    public final String toString() {
+        return super.toString() + "(string_index = " + string_index + ")";
+    }
+
+
+    /** @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);
+    }
 }

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantUtf8.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantUtf8.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantUtf8.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantUtf8.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License. 
  *
- */ 
+ */
 package org.apache.bcel.classfile;
 
-
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
@@ -32,81 +31,86 @@
  * @see     Constant
  */
 public final class ConstantUtf8 extends Constant {
-  private String bytes;
-  
-  /**
-   * Initialize from another object.
-   */
-  public ConstantUtf8(ConstantUtf8 c) {
-    this(c.getBytes());
-  }    
-  
-  /**
-   * Initialize instance from file data.
-   *
-   * @param file Input stream
-   * @throws IOException
-   */
-  ConstantUtf8(DataInputStream file) throws IOException
-  {    
-    super(Constants.CONSTANT_Utf8);
-
-    bytes = file.readUTF();
-  }    
-
-  /**
-   * @param bytes Data
-   */
-  public ConstantUtf8(String bytes)
-  {
-    super(Constants.CONSTANT_Utf8);
-
-    if(bytes == null)
-      throw new IllegalArgumentException("bytes must not be null!");
-
-    this.bytes  = bytes;
-  }    
-
-  /**
-   * 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.visitConstantUtf8(this);
-  }
-
-  /**
-   * Dump String in Utf8 format to file stream.
-   *
-   * @param file Output file stream
-   * @throws IOException
-   */ 
-  public final void dump(DataOutputStream file) throws IOException
-  {
-    file.writeByte(tag);
-    file.writeUTF(bytes);
-  }
-
-  /**
-   * @return Data converted to string.
-   */  
-  public final String getBytes() { return bytes; }    
-
-  /**
-   * @param bytes the raw bytes of this Utf-8
-   */
-  public final void setBytes(String bytes) {
-    this.bytes = bytes;
-  }    
-
-  /**
-   * @return String representation
-   */
-  public final String toString()
-  {
-    return super.toString() + "(\"" + Utility.replace(bytes, "\n", "\\n") + "\")";
-  }    
+
+    private String bytes;
+
+
+    /**
+     * Initialize from another object.
+     */
+    public ConstantUtf8(ConstantUtf8 c) {
+        this(c.getBytes());
+    }
+
+
+    /**
+     * Initialize instance from file data.
+     *
+     * @param file Input stream
+     * @throws IOException
+     */
+    ConstantUtf8(DataInputStream file) throws IOException {
+        super(Constants.CONSTANT_Utf8);
+        bytes = file.readUTF();
+    }
+
+
+    /**
+     * @param bytes Data
+     */
+    public ConstantUtf8(String bytes) {
+        super(Constants.CONSTANT_Utf8);
+        if (bytes == null) {
+            throw new IllegalArgumentException("bytes must not be null!");
+        }
+        this.bytes = bytes;
+    }
+
+
+    /**
+     * 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.visitConstantUtf8(this);
+    }
+
+
+    /**
+     * Dump String in Utf8 format to file stream.
+     *
+     * @param file Output file stream
+     * @throws IOException
+     */
+    public final void dump( DataOutputStream file ) throws IOException {
+        file.writeByte(tag);
+        file.writeUTF(bytes);
+    }
+
+
+    /**
+     * @return Data converted to string.
+     */
+    public final String getBytes() {
+        return bytes;
+    }
+
+
+    /**
+     * @param bytes the raw bytes of this Utf-8
+     */
+    public final void setBytes( String bytes ) {
+        this.bytes = bytes;
+    }
+
+
+    /**
+     * @return String representation
+     */
+    public final String toString() {
+        return super.toString() + "(\"" + Utility.replace(bytes, "\n", "\\n") + "\")";
+    }
 }

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantValue.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantValue.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantValue.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ConstantValue.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License. 
  *
- */ 
+ */
 package org.apache.bcel.classfile;
 
-
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
@@ -32,112 +31,125 @@
  * @see     Attribute
  */
 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());
-  }
-
-  /**
-   * Construct object from file stream.
-   * @param name_index Name index in constant pool
-   * @param length Content length in bytes
-   * @param file Input stream
-   * @param constant_pool Array of constants
-   * @throws IOException
-   */
-  ConstantValue(int name_index, int length, DataInputStream file,
-		ConstantPool constant_pool) throws IOException
-  {
-    this(name_index, length, file.readUnsignedShort(), constant_pool);
-  }    
-
-  /**
-   * @param name_index Name index in constant pool
-   * @param length Content length in bytes
-   * @param constantvalue_index Index in constant pool
-   * @param constant_pool Array of constants
-   */  
-  public ConstantValue(int name_index, int length, 
-		       int constantvalue_index,
-		       ConstantPool constant_pool)
-  {
-    super(Constants.ATTR_CONSTANT_VALUE, name_index, length, constant_pool);
-    this.constantvalue_index = constantvalue_index;
-  }    
-
-  /**
-   * 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.visitConstantValue(this);
-  }    
-  /**
-   * Dump constant value attribute to file stream on binary format.
-   *
-   * @param file Output file stream
-   * @throws IOException
-   */ 
-  public final void dump(DataOutputStream file) throws IOException
-  {
-    super.dump(file);
-    file.writeShort(constantvalue_index);
-  }    
-  /**
-   * @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;
-  }    
-
-  /**
-   * @return String representation of constant value.
-   */ 
-  public final String toString() {
-    Constant c = constant_pool.getConstant(constantvalue_index);
-	
-    String   buf;
-    int    i;
-
-    // Print constant to string depending on its type
-    switch(c.getTag()) {
-    case Constants.CONSTANT_Long:    buf = "" + ((ConstantLong)c).getBytes();    break;
-    case Constants.CONSTANT_Float:   buf = "" + ((ConstantFloat)c).getBytes();   break;
-    case Constants.CONSTANT_Double:  buf = "" + ((ConstantDouble)c).getBytes();  break;
-    case Constants.CONSTANT_Integer: buf = "" + ((ConstantInteger)c).getBytes(); break;
-    case Constants.CONSTANT_String:  
-      i   = ((ConstantString)c).getStringIndex();
-      c   = constant_pool.getConstant(i, Constants.CONSTANT_Utf8);
-      buf = "\"" + Utility.convertString(((ConstantUtf8)c).getBytes()) + "\"";
-      break;
-
-    default:
-      throw new IllegalStateException("Type of ConstValue invalid: " + c);
-    }
-
-    return buf;
-  }
-
-  /**
-   * @return deep copy of this attribute
-   */
-  public Attribute copy(ConstantPool _constant_pool) {
-    ConstantValue c = (ConstantValue)clone();
-    c.constant_pool = _constant_pool;
-    return c;
-  }
+    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());
+    }
+
+
+    /**
+     * Construct object from file stream.
+     * @param name_index Name index in constant pool
+     * @param length Content length in bytes
+     * @param file Input stream
+     * @param constant_pool Array of constants
+     * @throws IOException
+     */
+    ConstantValue(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
+            throws IOException {
+        this(name_index, length, file.readUnsignedShort(), constant_pool);
+    }
+
+
+    /**
+     * @param name_index Name index in constant pool
+     * @param length Content length in bytes
+     * @param constantvalue_index Index in constant pool
+     * @param constant_pool Array of constants
+     */
+    public ConstantValue(int name_index, int length, int constantvalue_index,
+            ConstantPool constant_pool) {
+        super(Constants.ATTR_CONSTANT_VALUE, name_index, length, constant_pool);
+        this.constantvalue_index = constantvalue_index;
+    }
+
+
+    /**
+     * 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.visitConstantValue(this);
+    }
+
+
+    /**
+     * Dump constant value attribute to file stream on binary format.
+     *
+     * @param file Output file stream
+     * @throws IOException
+     */
+    public final void dump( DataOutputStream file ) throws IOException {
+        super.dump(file);
+        file.writeShort(constantvalue_index);
+    }
+
+
+    /**
+     * @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;
+    }
+
+
+    /**
+     * @return String representation of constant value.
+     */
+    public final String toString() {
+        Constant c = constant_pool.getConstant(constantvalue_index);
+        String buf;
+        int i;
+        // Print constant to string depending on its type
+        switch (c.getTag()) {
+            case Constants.CONSTANT_Long:
+                buf = "" + ((ConstantLong) c).getBytes();
+                break;
+            case Constants.CONSTANT_Float:
+                buf = "" + ((ConstantFloat) c).getBytes();
+                break;
+            case Constants.CONSTANT_Double:
+                buf = "" + ((ConstantDouble) c).getBytes();
+                break;
+            case Constants.CONSTANT_Integer:
+                buf = "" + ((ConstantInteger) c).getBytes();
+                break;
+            case Constants.CONSTANT_String:
+                i = ((ConstantString) c).getStringIndex();
+                c = constant_pool.getConstant(i, Constants.CONSTANT_Utf8);
+                buf = "\"" + Utility.convertString(((ConstantUtf8) c).getBytes()) + "\"";
+                break;
+            default:
+                throw new IllegalStateException("Type of ConstValue invalid: " + c);
+        }
+        return buf;
+    }
+
+
+    /**
+     * @return deep copy of this attribute
+     */
+    public Attribute copy( ConstantPool _constant_pool ) {
+        ConstantValue c = (ConstantValue) clone();
+        c.constant_pool = _constant_pool;
+        return c;
+    }
 }

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/Deprecated.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/Deprecated.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/Deprecated.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/Deprecated.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License. 
  *
- */ 
+ */
 package org.apache.bcel.classfile;
 
-
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
@@ -32,105 +31,110 @@
  * @see     Attribute
  */
 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());
-  }    
-
-  /**
-   * @param name_index Index in constant pool to CONSTANT_Utf8
-   * @param length Content length in bytes
-   * @param bytes Attribute contents
-   * @param constant_pool Array of constants
-   */
-  public Deprecated(int name_index, int length, byte[] bytes,
-		    ConstantPool constant_pool)
-  {
-    super(Constants.ATTR_DEPRECATED, name_index, length, constant_pool);
-    this.bytes = bytes;
-  }    
-
-  /**
-   * Construct object from file stream.
-   * @param name_index Index in constant pool to CONSTANT_Utf8
-   * @param length Content length in bytes
-   * @param file Input stream
-   * @param constant_pool Array of constants
-   * @throws IOException
-   */
-  Deprecated(int name_index, int length, DataInputStream file,
-	     ConstantPool constant_pool) throws IOException
-  {
-    this(name_index, length, (byte [])null, constant_pool);
-
-    if(length > 0) {
-      bytes = new byte[length];
-      file.readFully(bytes);
-      System.err.println("Deprecated attribute with length > 0");
-    }
-  }    
-
-  /**
-   * 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.visitDeprecated(this);
-  }    
-
-  /**
-   * Dump source file attribute to file stream in binary format.
-   *
-   * @param file Output file stream
-   * @throws IOException
-   */ 
-  public final void dump(DataOutputStream file) throws IOException
-  {
-    super.dump(file);
-
-    if(length > 0)
-      file.write(bytes, 0, length);
-  }    
-
-  /**
-   * @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;
-  }    
-
-  /**
-   * @return attribute name
-   */ 
-  public final String toString() {
-    return Constants.ATTRIBUTE_NAMES[Constants.ATTR_DEPRECATED];
-  }
-
-  /**
-   * @return deep copy of this attribute
-   */
-  public Attribute copy(ConstantPool _constant_pool) {
-    Deprecated c = (Deprecated)clone();
-
-    if (bytes != null) {
-        c.bytes = new byte[bytes.length];
-        System.arraycopy(bytes, 0, c.bytes, 0, bytes.length);
-    }
-
-    c.constant_pool = _constant_pool;
-    return c;
-  }
+    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());
+    }
+
+
+    /**
+     * @param name_index Index in constant pool to CONSTANT_Utf8
+     * @param length Content length in bytes
+     * @param bytes Attribute contents
+     * @param constant_pool Array of constants
+     */
+    public Deprecated(int name_index, int length, byte[] bytes, ConstantPool constant_pool) {
+        super(Constants.ATTR_DEPRECATED, name_index, length, constant_pool);
+        this.bytes = bytes;
+    }
+
+
+    /**
+     * Construct object from file stream.
+     * @param name_index Index in constant pool to CONSTANT_Utf8
+     * @param length Content length in bytes
+     * @param file Input stream
+     * @param constant_pool Array of constants
+     * @throws IOException
+     */
+    Deprecated(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
+            throws IOException {
+        this(name_index, length, (byte[]) null, constant_pool);
+        if (length > 0) {
+            bytes = new byte[length];
+            file.readFully(bytes);
+            System.err.println("Deprecated attribute with length > 0");
+        }
+    }
+
+
+    /**
+     * 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.visitDeprecated(this);
+    }
+
+
+    /**
+     * Dump source file attribute to file stream in binary format.
+     *
+     * @param file Output file stream
+     * @throws IOException
+     */
+    public final void dump( DataOutputStream file ) throws IOException {
+        super.dump(file);
+        if (length > 0) {
+            file.write(bytes, 0, length);
+        }
+    }
+
+
+    /**
+     * @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;
+    }
+
+
+    /**
+     * @return attribute name
+     */
+    public final String toString() {
+        return Constants.ATTRIBUTE_NAMES[Constants.ATTR_DEPRECATED];
+    }
+
+
+    /**
+     * @return deep copy of this attribute
+     */
+    public Attribute copy( ConstantPool _constant_pool ) {
+        Deprecated c = (Deprecated) clone();
+        if (bytes != null) {
+            c.bytes = new byte[bytes.length];
+            System.arraycopy(bytes, 0, c.bytes, 0, bytes.length);
+        }
+        c.constant_pool = _constant_pool;
+        return c;
+    }
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.