|
|||||||||
| Home >> All >> org >> apache >> bcel >> [ generic overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.bcel.generic
Class ConstantPoolGen

java.lang.Objectorg.apache.bcel.generic.ConstantPoolGen
- All Implemented Interfaces:
- java.io.Serializable
- public class ConstantPoolGen
- extends java.lang.Object
- implements java.io.Serializable
- extends java.lang.Object
This class is used to build up a constant pool. The user adds constants via `addXXX' methods, `addString', `addClass', etc.. These methods return an index into the constant pool. Finally, `getFinalConstantPool()' returns the constant pool built up. Intermediate versions of the constant pool can be obtained with `getConstantPool()'. A constant pool has capacity for Constants.MAX_SHORT entries. Note that the first (0) is used by the JVM and that Double and Long constants need two slots.
- Version:
- $Id: ConstantPoolGen.java 386056 2006-03-15 11:31:56Z tcurdt $
| Nested Class Summary | |
private static class |
ConstantPoolGen.Index
|
| Field Summary | |
private java.util.Map |
class_table
|
protected org.apache.bcel.classfile.Constant[] |
constants
|
private java.util.Map |
cp_table
|
private static java.lang.String |
FIELDREF_DELIM
|
private static java.lang.String |
IMETHODREF_DELIM
|
protected int |
index
|
private static java.lang.String |
METHODREF_DELIM
|
private java.util.Map |
n_a_t_table
|
private static java.lang.String |
NAT_DELIM
|
protected int |
size
|
private java.util.Map |
string_table
|
private java.util.Map |
utf8_table
|
| Constructor Summary | |
ConstantPoolGen()
Create empty constant pool. |
|
ConstantPoolGen(org.apache.bcel.classfile.Constant[] cs)
Initialize with given array of constants. |
|
ConstantPoolGen(org.apache.bcel.classfile.ConstantPool cp)
Initialize with given constant pool. |
|
| Method Summary | |
int |
addArrayClass(ArrayType type)
Add a reference to an array class (e.g. |
private int |
addClass_(java.lang.String clazz)
|
int |
addClass(ObjectType type)
Add a new Class reference to the ConstantPool for a given type. |
int |
addClass(java.lang.String str)
Add a new Class reference to the ConstantPool, if it is not already in there. |
int |
addConstant(org.apache.bcel.classfile.Constant c,
ConstantPoolGen cp)
Import constant from another ConstantPool and return new index. |
int |
addDouble(double n)
Add a new double constant to the ConstantPool, if it is not already in there. |
int |
addFieldref(java.lang.String class_name,
java.lang.String field_name,
java.lang.String signature)
Add a new Fieldref constant to the ConstantPool, if it is not already in there. |
int |
addFloat(float n)
Add a new Float constant to the ConstantPool, if it is not already in there. |
int |
addInteger(int n)
Add a new Integer constant to the ConstantPool, if it is not already in there. |
int |
addInterfaceMethodref(MethodGen method)
|
int |
addInterfaceMethodref(java.lang.String class_name,
java.lang.String method_name,
java.lang.String signature)
Add a new InterfaceMethodref constant to the ConstantPool, if it is not already in there. |
int |
addLong(long n)
Add a new long constant to the ConstantPool, if it is not already in there. |
int |
addMethodref(MethodGen method)
|
int |
addMethodref(java.lang.String class_name,
java.lang.String method_name,
java.lang.String signature)
Add a new Methodref constant to the ConstantPool, if it is not already in there. |
int |
addNameAndType(java.lang.String name,
java.lang.String signature)
Add a new NameAndType constant to the ConstantPool if it is not already in there. |
int |
addString(java.lang.String str)
Add a new String constant to the ConstantPool, if it is not already in there. |
int |
addUtf8(java.lang.String n)
Add a new Utf8 constant to the ConstantPool, if it is not already in there. |
protected void |
adjustSize()
Resize internal array of constants. |
org.apache.bcel.classfile.Constant |
getConstant(int i)
|
org.apache.bcel.classfile.ConstantPool |
getConstantPool()
|
org.apache.bcel.classfile.ConstantPool |
getFinalConstantPool()
|
int |
getSize()
|
int |
lookupClass(java.lang.String str)
Look for ConstantClass in ConstantPool named `str'. |
int |
lookupDouble(double n)
Look for ConstantDouble in ConstantPool. |
int |
lookupFieldref(java.lang.String class_name,
java.lang.String field_name,
java.lang.String signature)
Look for ConstantFieldref in ConstantPool. |
int |
lookupFloat(float n)
Look for ConstantFloat in ConstantPool. |
int |
lookupInteger(int n)
Look for ConstantInteger in ConstantPool. |
int |
lookupInterfaceMethodref(MethodGen method)
|
int |
lookupInterfaceMethodref(java.lang.String class_name,
java.lang.String method_name,
java.lang.String signature)
Look for ConstantInterfaceMethodref in ConstantPool. |
int |
lookupLong(long n)
Look for ConstantLong in ConstantPool. |
int |
lookupMethodref(MethodGen method)
|
int |
lookupMethodref(java.lang.String class_name,
java.lang.String method_name,
java.lang.String signature)
Look for ConstantMethodref in ConstantPool. |
int |
lookupNameAndType(java.lang.String name,
java.lang.String signature)
Look for ConstantNameAndType in ConstantPool. |
int |
lookupString(java.lang.String str)
Look for ConstantString in ConstantPool containing String `str'. |
int |
lookupUtf8(java.lang.String n)
Look for ConstantUtf8 in ConstantPool. |
void |
setConstant(int i,
org.apache.bcel.classfile.Constant c)
Use with care! |
java.lang.String |
toString()
Convert this Object to a human-readable String. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
size
protected int size
constants
protected org.apache.bcel.classfile.Constant[] constants
index
protected int index
METHODREF_DELIM
private static final java.lang.String METHODREF_DELIM
- See Also:
- Constant Field Values
IMETHODREF_DELIM
private static final java.lang.String IMETHODREF_DELIM
- See Also:
- Constant Field Values
FIELDREF_DELIM
private static final java.lang.String FIELDREF_DELIM
- See Also:
- Constant Field Values
NAT_DELIM
private static final java.lang.String NAT_DELIM
- See Also:
- Constant Field Values
string_table
private java.util.Map string_table
class_table
private java.util.Map class_table
utf8_table
private java.util.Map utf8_table
n_a_t_table
private java.util.Map n_a_t_table
cp_table
private java.util.Map cp_table
| Constructor Detail |
ConstantPoolGen
public ConstantPoolGen(org.apache.bcel.classfile.Constant[] cs)
- Initialize with given array of constants.
ConstantPoolGen
public ConstantPoolGen(org.apache.bcel.classfile.ConstantPool cp)
- Initialize with given constant pool.
ConstantPoolGen
public ConstantPoolGen()
- Create empty constant pool.
| Method Detail |
adjustSize
protected void adjustSize()
- Resize internal array of constants.
lookupString
public int lookupString(java.lang.String str)
- Look for ConstantString in ConstantPool containing String `str'.
addString
public int addString(java.lang.String str)
- Add a new String constant to the ConstantPool, if it is not already in there.
lookupClass
public int lookupClass(java.lang.String str)
- Look for ConstantClass in ConstantPool named `str'.
addClass_
private int addClass_(java.lang.String clazz)
addClass
public int addClass(java.lang.String str)
- Add a new Class reference to the ConstantPool, if it is not already in there.
addClass
public int addClass(ObjectType type)
- Add a new Class reference to the ConstantPool for a given type.
addArrayClass
public int addArrayClass(ArrayType type)
- Add a reference to an array class (e.g. String[][]) as needed by MULTIANEWARRAY
instruction, e.g. to the ConstantPool.
lookupInteger
public int lookupInteger(int n)
- Look for ConstantInteger in ConstantPool.
addInteger
public int addInteger(int n)
- Add a new Integer constant to the ConstantPool, if it is not already in there.
lookupFloat
public int lookupFloat(float n)
- Look for ConstantFloat in ConstantPool.
addFloat
public int addFloat(float n)
- Add a new Float constant to the ConstantPool, if it is not already in there.
lookupUtf8
public int lookupUtf8(java.lang.String n)
- Look for ConstantUtf8 in ConstantPool.
addUtf8
public int addUtf8(java.lang.String n)
- Add a new Utf8 constant to the ConstantPool, if it is not already in there.
lookupLong
public int lookupLong(long n)
- Look for ConstantLong in ConstantPool.
addLong
public int addLong(long n)
- Add a new long constant to the ConstantPool, if it is not already in there.
lookupDouble
public int lookupDouble(double n)
- Look for ConstantDouble in ConstantPool.
addDouble
public int addDouble(double n)
- Add a new double constant to the ConstantPool, if it is not already in there.
lookupNameAndType
public int lookupNameAndType(java.lang.String name, java.lang.String signature)
- Look for ConstantNameAndType in ConstantPool.
addNameAndType
public int addNameAndType(java.lang.String name, java.lang.String signature)
- Add a new NameAndType constant to the ConstantPool if it is not already
in there.
lookupMethodref
public int lookupMethodref(java.lang.String class_name, java.lang.String method_name, java.lang.String signature)
- Look for ConstantMethodref in ConstantPool.
lookupMethodref
public int lookupMethodref(MethodGen method)
addMethodref
public int addMethodref(java.lang.String class_name, java.lang.String method_name, java.lang.String signature)
- Add a new Methodref constant to the ConstantPool, if it is not already
in there.
addMethodref
public int addMethodref(MethodGen method)
lookupInterfaceMethodref
public int lookupInterfaceMethodref(java.lang.String class_name, java.lang.String method_name, java.lang.String signature)
- Look for ConstantInterfaceMethodref in ConstantPool.
lookupInterfaceMethodref
public int lookupInterfaceMethodref(MethodGen method)
addInterfaceMethodref
public int addInterfaceMethodref(java.lang.String class_name, java.lang.String method_name, java.lang.String signature)
- Add a new InterfaceMethodref constant to the ConstantPool, if it is not already
in there.
addInterfaceMethodref
public int addInterfaceMethodref(MethodGen method)
lookupFieldref
public int lookupFieldref(java.lang.String class_name, java.lang.String field_name, java.lang.String signature)
- Look for ConstantFieldref in ConstantPool.
addFieldref
public int addFieldref(java.lang.String class_name, java.lang.String field_name, java.lang.String signature)
- Add a new Fieldref constant to the ConstantPool, if it is not already
in there.
getConstant
public org.apache.bcel.classfile.Constant getConstant(int i)
setConstant
public void setConstant(int i,
org.apache.bcel.classfile.Constant c)
- Use with care!
getConstantPool
public org.apache.bcel.classfile.ConstantPool getConstantPool()
getSize
public int getSize()
getFinalConstantPool
public org.apache.bcel.classfile.ConstantPool getFinalConstantPool()
toString
public java.lang.String toString()
- Description copied from class:
java.lang.Object - Convert this Object to a human-readable String.
There are no limits placed on how long this String
should be or what it should contain. We suggest you
make it as intuitive as possible to be able to place
it into System.out.println() 55
and such.
It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.
This method will be called when performing string concatenation with this object. If the result is
null, string concatenation will instead use"null".The default implementation returns
getClass().getName() + "@" + Integer.toHexString(hashCode()).
addConstant
public int addConstant(org.apache.bcel.classfile.Constant c, ConstantPoolGen cp)
- Import constant from another ConstantPool and return new index.
|
|||||||||
| Home >> All >> org >> apache >> bcel >> [ generic overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.apache.bcel.generic.ConstantPoolGen