src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Deprecated.java
changeset 55496 8e0ae3830fca
parent 47216 71c04702a3d5
equal deleted inserted replaced
55495:badfa812b82a 55496:8e0ae3830fca
    26 
    26 
    27 import com.sun.org.apache.bcel.internal.Const;
    27 import com.sun.org.apache.bcel.internal.Const;
    28 
    28 
    29 /**
    29 /**
    30  * This class is derived from <em>Attribute</em> and denotes that this is a
    30  * This class is derived from <em>Attribute</em> and denotes that this is a
    31  * deprecated method. It is instantiated from the
    31  * deprecated method.
    32  * <em>Attribute.readAttribute()</em> method.
    32  * It is instantiated from the <em>Attribute.readAttribute()</em> method.
    33  *
    33  *
    34  * @version $Id: Deprecated.java 1749603 2016-06-21 20:50:19Z ggregory $
    34  * @version $Id$
    35  * @see Attribute
    35  * @see     Attribute
    36  */
    36  */
    37 public final class Deprecated extends Attribute {
    37 public final class Deprecated extends Attribute {
    38 
    38 
    39     private byte[] bytes;
    39     private byte[] bytes;
       
    40 
    40 
    41 
    41     /**
    42     /**
    42      * Initialize from another object. Note that both objects use the same
    43      * Initialize from another object. Note that both objects use the same
    43      * references (shallow copy). Use clone() for a physical copy.
    44      * references (shallow copy). Use clone() for a physical copy.
    44      */
    45      */
    45     public Deprecated(final Deprecated c) {
    46     public Deprecated(final Deprecated c) {
    46         this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool());
    47         this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool());
    47     }
    48     }
       
    49 
    48 
    50 
    49     /**
    51     /**
    50      * @param name_index Index in constant pool to CONSTANT_Utf8
    52      * @param name_index Index in constant pool to CONSTANT_Utf8
    51      * @param length Content length in bytes
    53      * @param length Content length in bytes
    52      * @param bytes Attribute contents
    54      * @param bytes Attribute contents
    54      */
    56      */
    55     public Deprecated(final int name_index, final int length, final byte[] bytes, final ConstantPool constant_pool) {
    57     public Deprecated(final int name_index, final int length, final byte[] bytes, final ConstantPool constant_pool) {
    56         super(Const.ATTR_DEPRECATED, name_index, length, constant_pool);
    58         super(Const.ATTR_DEPRECATED, name_index, length, constant_pool);
    57         this.bytes = bytes;
    59         this.bytes = bytes;
    58     }
    60     }
       
    61 
    59 
    62 
    60     /**
    63     /**
    61      * Construct object from input stream.
    64      * Construct object from input stream.
    62      *
    65      *
    63      * @param name_index Index in constant pool to CONSTANT_Utf8
    66      * @param name_index Index in constant pool to CONSTANT_Utf8
    74             input.readFully(bytes);
    77             input.readFully(bytes);
    75             System.err.println("Deprecated attribute with length > 0");
    78             System.err.println("Deprecated attribute with length > 0");
    76         }
    79         }
    77     }
    80     }
    78 
    81 
       
    82 
    79     /**
    83     /**
    80      * Called by objects that are traversing the nodes of the tree implicitely
    84      * Called by objects that are traversing the nodes of the tree implicitely
    81      * defined by the contents of a Java class. I.e., the hierarchy of methods,
    85      * defined by the contents of a Java class. I.e., the hierarchy of methods,
    82      * fields, attributes, etc. spawns a tree of objects.
    86      * fields, attributes, etc. spawns a tree of objects.
    83      *
    87      *
    84      * @param v Visitor object
    88      * @param v Visitor object
    85      */
    89      */
    86     @Override
    90     @Override
    87     public void accept(final Visitor v) {
    91     public void accept( final Visitor v ) {
    88         v.visitDeprecated(this);
    92         v.visitDeprecated(this);
    89     }
    93     }
       
    94 
    90 
    95 
    91     /**
    96     /**
    92      * Dump source file attribute to file stream in binary format.
    97      * Dump source file attribute to file stream in binary format.
    93      *
    98      *
    94      * @param file Output file stream
    99      * @param file Output file stream
    95      * @throws IOException
   100      * @throws IOException
    96      */
   101      */
    97     @Override
   102     @Override
    98     public final void dump(final DataOutputStream file) throws IOException {
   103     public final void dump( final DataOutputStream file ) throws IOException {
    99         super.dump(file);
   104         super.dump(file);
   100         if (super.getLength() > 0) {
   105         if (super.getLength() > 0) {
   101             file.write(bytes, 0, super.getLength());
   106             file.write(bytes, 0, super.getLength());
   102         }
   107         }
   103     }
   108     }
       
   109 
   104 
   110 
   105     /**
   111     /**
   106      * @return data bytes.
   112      * @return data bytes.
   107      */
   113      */
   108     public final byte[] getBytes() {
   114     public final byte[] getBytes() {
   109         return bytes;
   115         return bytes;
   110     }
   116     }
   111 
   117 
       
   118 
   112     /**
   119     /**
   113      * @param bytes the raw bytes that represents this byte array
   120      * @param bytes the raw bytes that represents this byte array
   114      */
   121      */
   115     public final void setBytes(final byte[] bytes) {
   122     public final void setBytes( final byte[] bytes ) {
   116         this.bytes = bytes;
   123         this.bytes = bytes;
   117     }
   124     }
       
   125 
   118 
   126 
   119     /**
   127     /**
   120      * @return attribute name
   128      * @return attribute name
   121      */
   129      */
   122     @Override
   130     @Override
   123     public final String toString() {
   131     public final String toString() {
   124         return Const.getAttributeName(Const.ATTR_DEPRECATED);
   132         return Const.getAttributeName(Const.ATTR_DEPRECATED);
   125     }
   133     }
   126 
   134 
       
   135 
   127     /**
   136     /**
   128      * @return deep copy of this attribute
   137      * @return deep copy of this attribute
   129      */
   138      */
   130     @Override
   139     @Override
   131     public Attribute copy(final ConstantPool _constant_pool) {
   140     public Attribute copy( final ConstantPool _constant_pool ) {
   132         final Deprecated c = (Deprecated) clone();
   141         final Deprecated c = (Deprecated) clone();
   133         if (bytes != null) {
   142         if (bytes != null) {
   134             c.bytes = new byte[bytes.length];
   143             c.bytes = new byte[bytes.length];
   135             System.arraycopy(bytes, 0, c.bytes, 0, bytes.length);
   144             System.arraycopy(bytes, 0, c.bytes, 0, bytes.length);
   136         }
   145         }