fr.umlv.corosol.classfile.constant
Interface JConstantPool

All Superinterfaces:
JClassFileItem, JObject
All Known Implementing Classes:
DefaultJConstantPool

public interface JConstantPool
extends JClassFileItem

An object of the JConstantPool interface represents the constant pool of a classfile.

The constant pool is a table of structures representing various string constants, class and interface names, field names, and other constants that are referred to within the classfile structure and its substructures. Those data is designed to be symbolic informations. Java virtual machine instructions do not rely on the runtime layout of classes, interfaces, class instances, or arrays. Instead, instructions refer to those symbolic information in the constant pool table.

Author:
Christophe Deleray
See Also:
JConstant

Method Summary
 int addConstant(JConstant constant)
          Adds the specified constant in this constant pool.
 int addConstantClass(java.lang.String className)
          Adds a new CONSTANT_Class_info entry corresponding to the specified class name.
 int addConstantDouble(double doubleValue)
          Adds a new CONSTANT_Double_info entry initialized with the specified value.
 int addConstantFieldref(java.lang.String className, java.lang.String name, java.lang.String desc)
          Adds a new CONSTANT_Fieldref_info entry.
 int addConstantFloat(float floatValue)
          Adds a new CONSTANT_Float_info entry initialized with the specified value.
 int addConstantInteger(int intValue)
          Adds a new CONSTANT_Integer_info entry initialized with the specified value.
 int addConstantInterfaceMethodref(java.lang.String className, java.lang.String name, java.lang.String desc)
          Adds a new CONSTANT_InterfaceMethodref_info entry.
 int addConstantLong(long longValue)
          Adds a new CONSTANT_Long_info entry initialized with the specified value.
 int addConstantMethodref(java.lang.String className, java.lang.String name, java.lang.String desc)
          Adds a new CONSTANT_Methodref_info entry.
 int addConstantNameAndType(java.lang.String name, java.lang.String descriptor)
          Adds a new CONSTANT_NameAndType_info entry.
 int addConstantString(java.lang.String string)
          Adds a new CONSTANT_String_info entry initialized with the specified string value.
 int addConstantUtf8(java.lang.String string)
          Adds a new CONSTANT_Utf8_info entry initialized with the specified string value.
 JConstant getConstant(int index)
          Returns the entry at the specified position in this constant pool.
 JConstant[] getConstants()
          Returns an array containing all the constant pool entries.
 int length()
          Returns the number of entries in this constant pool.
 java.lang.String toString()
          Returns a string representation of this constant pool, containing the String representation of each entry.
 
Methods inherited from interface fr.umlv.corosol.classfile.JClassFileItem
getConstantPool, readItem, setConstantPool, writeItem
 

Method Detail

addConstant

int addConstant(JConstant constant)
Adds the specified constant in this constant pool.

Parameters:
constant - entry to be added to this constant pool
Returns:
the index of this entry int this constant pool

addConstantClass

int addConstantClass(java.lang.String className)
Adds a new CONSTANT_Class_info entry corresponding to the specified class name.

Parameters:
className - a class name
Returns:
the index of this new constant pool entry

addConstantNameAndType

int addConstantNameAndType(java.lang.String name,
                           java.lang.String descriptor)
Adds a new CONSTANT_NameAndType_info entry.

Parameters:
name - the name of a field or a method
descriptor - the descriptor of a field or a method
Returns:
the index of this new constant pool entry

addConstantFieldref

int addConstantFieldref(java.lang.String className,
                        java.lang.String name,
                        java.lang.String desc)
Adds a new CONSTANT_Fieldref_info entry.

Parameters:
className - the name of a class
name - the name of the field
desc - the descriptor of the field
Returns:
the index of this new constant pool entry

addConstantMethodref

int addConstantMethodref(java.lang.String className,
                         java.lang.String name,
                         java.lang.String desc)
Adds a new CONSTANT_Methodref_info entry.

Parameters:
className - the name of a class
name - the name of the field
desc - the descriptor of the field
Returns:
the index of this new constant pool entry

addConstantInterfaceMethodref

int addConstantInterfaceMethodref(java.lang.String className,
                                  java.lang.String name,
                                  java.lang.String desc)
Adds a new CONSTANT_InterfaceMethodref_info entry.

Parameters:
className - the name of a class
name - the name of the interface method
desc - the descriptor of the interface method
Returns:
the index of this new constant pool entry

addConstantString

int addConstantString(java.lang.String string)
Adds a new CONSTANT_String_info entry initialized with the specified string value.

Parameters:
string - the string to be stored in the new entry
Returns:
the index of this new constant pool entry

addConstantUtf8

int addConstantUtf8(java.lang.String string)
Adds a new CONSTANT_Utf8_info entry initialized with the specified string value.

Parameters:
string - the string to be stored in the new entry
Returns:
the index of this new constant pool entry

addConstantInteger

int addConstantInteger(int intValue)
Adds a new CONSTANT_Integer_info entry initialized with the specified value.

Parameters:
intValue - the value to be stored in the new entry
Returns:
the index of this new constant pool entry

addConstantFloat

int addConstantFloat(float floatValue)
Adds a new CONSTANT_Float_info entry initialized with the specified value.

Parameters:
floatValue - the value to be stored in the new entry
Returns:
the index of this new constant pool entry

addConstantLong

int addConstantLong(long longValue)
Adds a new CONSTANT_Long_info entry initialized with the specified value.

Parameters:
longValue - the value to be stored in the new entry
Returns:
the index of this new constant pool entry

addConstantDouble

int addConstantDouble(double doubleValue)
Adds a new CONSTANT_Double_info entry initialized with the specified value.

Parameters:
doubleValue - the value to be stored in the new entry
Returns:
the index of this new constant pool entry

length

int length()
Returns the number of entries in this constant pool.

Returns:
the number of entries in this constant pool

getConstant

JConstant getConstant(int index)
Returns the entry at the specified position in this constant pool.

Parameters:
index - index of entry to return
Returns:
the entry at the specified position

getConstants

JConstant[] getConstants()
Returns an array containing all the constant pool entries.

Returns:
an array containing all the constant pool entries.

toString

java.lang.String toString()
Returns a string representation of this constant pool, containing the String representation of each entry.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this constant pool