|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.go.trove.classfile.ConstantPool
This class corresponds to the constant_pool structure as defined in section 4.4 of The Java Virtual Machine Specification.
ConstantPool entries are not written out in the order in which they were added to it. Instead, their ordering is changed such that String, Integer and Float constants are written out first. This provides a slight optimization for referencing these constants from a code attribute. It means that Opcode.LDC will more likely be used (one-byte index) than Opcode.LDC_W (two-byte index).
CodeAttr,
Opcode| Method Summary | |
ConstantInfo |
addConstant(ConstantInfo constant)
Will only insert into the pool if the constant is not already in the pool. |
ConstantClassInfo |
addConstantClass(java.lang.String className)
Get or create a constant from the constant pool representing a class. |
ConstantClassInfo |
addConstantClass(java.lang.String className,
int dim)
Get or create a constant from the constant pool representing an array class. |
ConstantClassInfo |
addConstantClass(TypeDescriptor type)
Get or create a constant from the constant pool representing a class. |
ConstantMethodInfo |
addConstantConstructor(java.lang.String className,
TypeDescriptor[] params)
Get or create a constant from the constant pool representing a constructor in any class. |
ConstantDoubleInfo |
addConstantDouble(double value)
Get or create a constant double from the constant pool. |
ConstantFieldInfo |
addConstantField(java.lang.String className,
java.lang.String fieldName,
TypeDescriptor type)
Get or create a constant from the constant pool representing a field in any class. |
ConstantFloatInfo |
addConstantFloat(float value)
Get or create a constant float from the constant pool. |
ConstantIntegerInfo |
addConstantInteger(int value)
Get or create a constant integer from the constant pool. |
ConstantInterfaceMethodInfo |
addConstantInterfaceMethod(java.lang.String className,
java.lang.String methodName,
TypeDescriptor ret,
TypeDescriptor[] params)
Get or create a constant from the constant pool representing an interface method in any interface. |
ConstantLongInfo |
addConstantLong(long value)
Get or create a constant long from the constant pool. |
ConstantMethodInfo |
addConstantMethod(java.lang.String className,
java.lang.String methodName,
TypeDescriptor ret,
TypeDescriptor[] params)
Get or create a constant from the constant pool representing a method in any class. |
ConstantNameAndTypeInfo |
addConstantNameAndType(java.lang.String name,
Descriptor type)
Get or create a constant name and type structure from the constant pool. |
ConstantStringInfo |
addConstantString(java.lang.String str)
Get or create a constant string from the constant pool. |
ConstantUTFInfo |
addConstantUTF(java.lang.String str)
Get or create a constant UTF string from the constant pool. |
java.util.Set |
getAllConstants()
Returns all the constants in the pool, in no particular order. |
ConstantInfo |
getConstant(int index)
Returns a constant from the pool by index, or throws an exception if not found. |
int |
getSize()
Returns the number of constants in the pool. |
static ConstantPool |
readFrom(java.io.DataInput din)
|
void |
writeTo(java.io.DataOutput dout)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public ConstantInfo getConstant(int index)
java.lang.ArrayIndexOutOfBoundsException - if index is out of range.public java.util.Set getAllConstants()
public int getSize()
public ConstantClassInfo addConstantClass(java.lang.String className)
public ConstantClassInfo addConstantClass(java.lang.String className,
int dim)
dim - Number of array dimensions.public ConstantClassInfo addConstantClass(TypeDescriptor type)
public ConstantFieldInfo addConstantField(java.lang.String className,
java.lang.String fieldName,
TypeDescriptor type)
public ConstantMethodInfo addConstantMethod(java.lang.String className,
java.lang.String methodName,
TypeDescriptor ret,
TypeDescriptor[] params)
public ConstantInterfaceMethodInfo addConstantInterfaceMethod(java.lang.String className,
java.lang.String methodName,
TypeDescriptor ret,
TypeDescriptor[] params)
public ConstantMethodInfo addConstantConstructor(java.lang.String className,
TypeDescriptor[] params)
public ConstantIntegerInfo addConstantInteger(int value)
public ConstantLongInfo addConstantLong(long value)
public ConstantFloatInfo addConstantFloat(float value)
public ConstantDoubleInfo addConstantDouble(double value)
public ConstantStringInfo addConstantString(java.lang.String str)
public ConstantUTFInfo addConstantUTF(java.lang.String str)
public ConstantNameAndTypeInfo addConstantNameAndType(java.lang.String name,
Descriptor type)
public ConstantInfo addConstant(ConstantInfo constant)
public void writeTo(java.io.DataOutput dout)
throws java.io.IOException
public static ConstantPool readFrom(java.io.DataInput din)
throws java.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||