com.vladium.jcd.cls.attribute
Class ConstantValueAttribute_info
java.lang.Object
com.vladium.jcd.cls.attribute.Attribute_info
com.vladium.jcd.cls.attribute.ConstantValueAttribute_info
- All Implemented Interfaces:
- IClassFormatOutput, java.lang.Cloneable
public final class ConstantValueAttribute_info
- extends Attribute_info
The ConstantValue attribute is a fixed-length attribute used in the attributes
table of the Field_info
structures. A ConstantValue
attribute represents the value of a constant field that must be (explicitly or
implicitly) static; that is, the ACC_STATIC bit in the flags item of the
Field_info structure must be set. The field is not required to be final. There
can be no more than one ConstantValue attribute in the attributes table of a
given Field_info structure. The constant field represented by the Field_info
structure is assigned the value referenced by its ConstantValue attribute as
part of its initialization.
The ConstantValue attribute has the format
ConstantValue_attribute {
u2 attribute_name_index;
u4 attribute_length;
u2 constantvalue_index;
}
The value of the constantvalue_index item must be a valid index into the constant
pool table. The constant pool entry at that index must give the constant value
represented by this attribute.
The constant pool entry must be of a type appropriate to the field, as shown below:
Field Type | Entry Type |
long | CONSTANT_Long |
float | CONSTANT_Float |
double | CONSTANT_Double |
int, short, char, byte, boolean | CONSTANT_Integer |
java.lang.String | CONSTANT_String |
- Author:
- (C) 2001, Vlad Roubtsov
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
m_value_index
public int m_value_index
DEBUG
private static final boolean DEBUG
- See Also:
- Constant Field Values
ConstantValueAttribute_info
public ConstantValueAttribute_info(int attribute_name_index,
int value_index)
ConstantValueAttribute_info
ConstantValueAttribute_info(int attribute_name_index,
long attribute_length,
UDataInputStream bytes)
throws java.io.IOException
- Throws:
java.io.IOException
getValue
public CONSTANT_literal_info getValue(ClassDef cls)
length
public long length()
- Description copied from class:
Attribute_info
- Returns the total length of this attribute when converted to
.class format [including the 6-byte header]
- Specified by:
length
in class Attribute_info
accept
public void accept(IAttributeVisitor visitor,
java.lang.Object ctx)
- Specified by:
accept
in class Attribute_info
toString
public java.lang.String toString()
- Specified by:
toString
in class Attribute_info
clone
public java.lang.Object clone()
- Performs a deep copy.
- Overrides:
clone
in class Attribute_info
writeInClassFormat
public void writeInClassFormat(UDataOutputStream out)
throws java.io.IOException
- Specified by:
writeInClassFormat
in interface IClassFormatOutput
- Overrides:
writeInClassFormat
in class Attribute_info
- Throws:
java.io.IOException