harpoon.IR.RawClass
Class AttributeConstantValue

java.lang.Object
  extended by harpoon.IR.RawClass.Attribute
      extended by harpoon.IR.RawClass.AttributeConstantValue

public class AttributeConstantValue
extends Attribute

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.

CORRECTION FROM ERRATA: If a non-static field has a ConstantValue attribute, then the attribute is silently ignored.

Version:
$Id: AttributeConstantValue.java,v 1.3 2003/09/05 21:45:15 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>
See Also:
Attribute, FieldInfo, ClassFile

Field Summary
static String ATTRIBUTE_NAME
          The string naming this Attribute type.
 int constantvalue_index
          The value of the constantvalue_index must be a valid index into the constant_pool table.
 
Fields inherited from class harpoon.IR.RawClass.Attribute
attribute_name_index, parent
 
Constructor Summary
AttributeConstantValue(ClassFile parent, int attribute_name_index, int constantvalue_index)
          Constructor.
 
Method Summary
 long attribute_length()
          The value of the attribute_length item indicates the length of the attribute, excluding the initial six bytes.
 Constant constantvalue_index()
           
 void print(PrintWriter pw, int indent)
          Pretty-print the contents of this attribute.
 void write(ClassDataOutputStream out)
          Write to bytecode stream.
 
Methods inherited from class harpoon.IR.RawClass.Attribute
attribute_name_index, attribute_name, read, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ATTRIBUTE_NAME

public static final String ATTRIBUTE_NAME
The string naming this Attribute type.

See Also:
Constant Field Values

constantvalue_index

public int constantvalue_index
The value of the constantvalue_index 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.

Constructor Detail

AttributeConstantValue

public AttributeConstantValue(ClassFile parent,
                              int attribute_name_index,
                              int constantvalue_index)
Constructor.

Method Detail

attribute_length

public long attribute_length()
Description copied from class: Attribute
The value of the attribute_length item indicates the length of the attribute, excluding the initial six bytes.

Specified by:
attribute_length in class Attribute

constantvalue_index

public Constant constantvalue_index()

write

public void write(ClassDataOutputStream out)
           throws IOException
Write to bytecode stream.

Specified by:
write in class Attribute
Throws:
IOException

print

public void print(PrintWriter pw,
                  int indent)
Pretty-print the contents of this attribute.

Overrides:
print in class Attribute
Parameters:
indent - the indentation level to use.