Class constValueAttr


public class constValueAttr
extends attrInfo

Represent a ConstantValue attribute.

The JVM Specification (4.7.3) states:

The constValueAttr is a fixed length attribute used in the "attributes" table of the field info structure. A constValueAttr represents the value of a constant field that must be (explicitly or implicitly) static; that is the ACC_STATIC bit in the flags item o fthe field_info structure must be set. The field is not required to be final. There can be no more than one constValueAttr 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 constValueAttr attribute as part of its initialization.

Every JVM is required to recognize the constValueAttr. There may be other locally defined attributes which are ignored in general but may be used by a specific combination of Java compiler and JVM (so much for portability).

The constValueAttr is

ConstantValue_attribute {
u2 attribute_name_index;
u4 attribute_length;    
u2 constantvalue_index;

The attribute_name_index and attribute length are read by the attrFactory.allocAttr method. These values are passed into the class constructor.

The constantvalue_index is the index into the constant pool for a long, float, double, int (for int, short, char, byte and boolean) or String. Question: What is the ConstantValue attribute for mondoRef, since its type is not a base type, but it is static. class mondo { int p, d, q; } class foobar { static mondo mondoRef = null; ... }

Ian Kaplan

Field Summary
(package private)  constBase constValue
Fields inherited from class attr.attrInfo
attrName, len
Fields inherited from class util.dataRead
Constructor Summary
constValueAttr(java.lang.String name, int length, dStream, constPool constPoolSec)
Method Summary
 constBase getConstVal()
 void pr()
Methods inherited from class attr.attrInfo
Methods inherited from class util.dataRead
getBytesRead, readU1, readU2, readU4
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait

Field Detail


constBase constValue
Constructor Detail


public constValueAttr(java.lang.String name,
                      int length,
                      constPool constPoolSec)
Method Detail


public constBase getConstVal()


public void pr()
pr in class attrInfo