Class ConstantPool

java.lang.Object
  |
  +--ConstantPool

class ConstantPool
extends java.lang.Object
implements JVM


Field Summary
(package private)  cp_info[] table
           
 
Constructor Summary
(package private) ConstantPool(java.io.DataInput in)
           
 
Method Summary
(package private)  int findClassnameIndex(Klass cl)
          find the constant pool index of a given class.
(package private)  int findClassnameIndex(java.lang.String classname)
          find the constant pool index of a class with a given name.
(package private)  int findNameAndTypeIndex(java.lang.String name, java.lang.String signature)
          find the constant pool index of a given NameAndType entry.
(package private)  int findStringIndex(java.lang.String string)
          find the constant pool index of a given String.
(package private)  java.lang.String getClassname(int index)
          get the classname for a CONSTANT_Class_info entry
(package private)  double getDouble(int index)
          get the double value at a given index.
(package private)  long getDoubleAsLongBits(int index)
          get an long-bits version of the double value at a given index.
(package private)  FieldInfo getFieldInfo(int index)
          get a FieldInfo from a CONSTANT_Fieldref_info entry
(package private)  float getFloat(int index)
          get the float value at a given index.
(package private)  int getFloatAsIntBits(int index)
          get an int-bits version of the float value at a given index.
(package private)  int getInteger(int index)
          get the integer value at a given index.
(package private)  MethodInfo getInterfaceMethodInfo(int index)
          get a MethodInfo from a CONSTANT_InterfaceMethodref_info entry
(package private)  Klass getKlass(int index)
          get the class descriptor for a CONSTANT_Class_info entry
(package private)  long getLong(int index)
          get the long value at a given index.
(package private)  MethodInfo getMethodInfo(int index)
          get a MethodInfo from a CONSTANT_Methodref_info or a CONSTANT_InterfaceMethodref_info entry
(package private)  java.lang.String getSignature(int index)
          get the type signature of a java language constant stored in the constant pool at the given index.
(package private)  java.lang.String getString(int index)
          get a string from a CONSTANT_Utf8_info or CONSTANT_String_info entry
(package private)  boolean isString(int index)
          check for the entry being a String.
(package private)  void write(java.io.DataOutput out)
          write this ConstantPool to a given stream, producing a classfile-compatible representation.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

table

cp_info[] table
Constructor Detail

ConstantPool

ConstantPool(java.io.DataInput in)
       throws java.io.IOException
Method Detail

write

void write(java.io.DataOutput out)
     throws java.io.IOException
write this ConstantPool to a given stream, producing a classfile-compatible representation.
Parameters:
out - the stream (implementing the DataOutput interface).

getSignature

java.lang.String getSignature(int index)
get the type signature of a java language constant stored in the constant pool at the given index. Returns null if entry isn't a java language constant (e.g. entry is a methodref info).

getInteger

int getInteger(int index)
get the integer value at a given index.

getFloat

float getFloat(int index)
get the float value at a given index.

getFloatAsIntBits

int getFloatAsIntBits(int index)
get an int-bits version of the float value at a given index.

getLong

long getLong(int index)
get the long value at a given index.

getDouble

double getDouble(int index)
get the double value at a given index.

getDoubleAsLongBits

long getDoubleAsLongBits(int index)
get an long-bits version of the double value at a given index.

isString

boolean isString(int index)
check for the entry being a String.

getString

java.lang.String getString(int index)
get a string from a CONSTANT_Utf8_info or CONSTANT_String_info entry

findStringIndex

int findStringIndex(java.lang.String string)
find the constant pool index of a given String.
Parameters:
string - the string we are looking for.
Returns:
the index of the constant pool entry for that string, or -1, if no such constant pool entry.

getClassname

java.lang.String getClassname(int index)
get the classname for a CONSTANT_Class_info entry

findClassnameIndex

int findClassnameIndex(java.lang.String classname)
find the constant pool index of a class with a given name.
Parameters:
classname - the classname in slash-syntax.
Returns:
the index of the constant pool entry for that classname, or -1, if no such constant pool entry.

findClassnameIndex

int findClassnameIndex(Klass cl)
find the constant pool index of a given class.
Parameters:
cl - the class to search for.
Returns:
the index of the constant pool entry for that classname, or -1, if no such constant pool entry.

getKlass

Klass getKlass(int index)
get the class descriptor for a CONSTANT_Class_info entry

getFieldInfo

FieldInfo getFieldInfo(int index)
get a FieldInfo from a CONSTANT_Fieldref_info entry

getMethodInfo

MethodInfo getMethodInfo(int index)
get a MethodInfo from a CONSTANT_Methodref_info or a CONSTANT_InterfaceMethodref_info entry

getInterfaceMethodInfo

MethodInfo getInterfaceMethodInfo(int index)
get a MethodInfo from a CONSTANT_InterfaceMethodref_info entry

findNameAndTypeIndex

int findNameAndTypeIndex(java.lang.String name,
                         java.lang.String signature)
find the constant pool index of a given NameAndType entry.
Parameters:
name - the name to search for.
signature - the type to search for.
Returns:
the index of the constant pool entry, or -1, if no such constant pool entry.