public class ConstantPoolGen extends Object
Constant
Modifier and Type | Field and Description |
---|---|
protected Constant[] |
constants
Deprecated.
(since 6.0) will be made private; do not access directly, use getter/setter
|
protected int |
index
Deprecated.
(since 6.0) will be made private; do not access directly, use getSize()
|
protected int |
size
Deprecated.
(since 6.0) will be made private; do not access directly, use getter/setter
|
Constructor and Description |
---|
ConstantPoolGen()
Constructs a new empty constant pool.
|
ConstantPoolGen(Constant[] cs)
Constructs a new instance with the given array of constants.
|
ConstantPoolGen(ConstantPool cp)
Constructs a new instance with the given constant pool.
|
Modifier and Type | Method and Description |
---|---|
int |
addArrayClass(ArrayType type)
Add a reference to an array class (e.g.
|
int |
addClass(ObjectType type)
Add a new Class reference to the ConstantPool for a given type.
|
int |
addClass(String str)
Add a new Class reference to the ConstantPool, if it is not already in there.
|
int |
addConstant(Constant constant,
ConstantPoolGen cpGen)
Adds a constant from another ConstantPool and returns the new index.
|
int |
addDouble(double n)
Add a new double constant to the ConstantPool, if it is not already in there.
|
int |
addFieldref(String className,
String fieldName,
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(String className,
String methodName,
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(String className,
String methodName,
String signature)
Add a new Methodref constant to the ConstantPool, if it is not already in there.
|
int |
addNameAndType(String name,
String signature)
Add a new NameAndType constant to the ConstantPool if it is not already in there.
|
int |
addString(String str)
Add a new String constant to the ConstantPool, if it is not already in there.
|
int |
addUtf8(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.
|
Constant |
getConstant(int i) |
ConstantPool |
getConstantPool() |
ConstantPool |
getFinalConstantPool() |
int |
getSize() |
int |
lookupClass(String str)
Look for ConstantClass in ConstantPool named 'str'.
|
int |
lookupDouble(double n)
Look for ConstantDouble in ConstantPool.
|
int |
lookupFieldref(String className,
String fieldName,
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(String className,
String methodName,
String signature)
Look for ConstantInterfaceMethodref in ConstantPool.
|
int |
lookupLong(long n)
Look for ConstantLong in ConstantPool.
|
int |
lookupMethodref(MethodGen method) |
int |
lookupMethodref(String className,
String methodName,
String signature)
Look for ConstantMethodref in ConstantPool.
|
int |
lookupNameAndType(String name,
String signature)
Look for ConstantNameAndType in ConstantPool.
|
int |
lookupString(String str)
Look for ConstantString in ConstantPool containing String 'str'.
|
int |
lookupUtf8(String n)
Look for ConstantUtf8 in ConstantPool.
|
void |
setConstant(int i,
Constant c)
Use with care!
|
String |
toString() |
@Deprecated protected int size
@Deprecated protected Constant[] constants
@Deprecated protected int index
public ConstantPoolGen()
public ConstantPoolGen(Constant[] cs)
cs
- array of given constants, new ones will be appendedpublic ConstantPoolGen(ConstantPool cp)
cp
- the constant pool.public int addArrayClass(ArrayType type)
type
- type of array classpublic int addClass(ObjectType type)
type
- Class to addpublic int addClass(String str)
str
- Class to addpublic int addConstant(Constant constant, ConstantPoolGen cpGen)
constant
- The constant to add.cpGen
- Source pool.public int addDouble(double n)
n
- Double number to addpublic int addFieldref(String className, String fieldName, String signature)
className
- class name string to addfieldName
- field name string to addsignature
- signature string to addpublic int addFloat(float n)
n
- Float number to addpublic int addInteger(int n)
n
- integer number to addpublic int addInterfaceMethodref(MethodGen method)
public int addInterfaceMethodref(String className, String methodName, String signature)
className
- class name string to addmethodName
- method name string to addsignature
- signature string to addpublic int addLong(long n)
n
- Long number to addpublic int addMethodref(MethodGen method)
public int addMethodref(String className, String methodName, String signature)
className
- class name string to addmethodName
- method name string to addsignature
- method signature string to addpublic int addNameAndType(String name, String signature)
name
- Name string to addsignature
- signature string to addpublic int addString(String str)
str
- String to addpublic int addUtf8(String n)
n
- Utf8 string to addprotected void adjustSize()
public Constant getConstant(int i)
i
- index in constant poolpublic ConstantPool getConstantPool()
public ConstantPool getFinalConstantPool()
public int getSize()
public int lookupClass(String str)
str
- String to search forpublic int lookupDouble(double n)
n
- Double number to look forpublic int lookupFieldref(String className, String fieldName, String signature)
className
- Where to find methodfieldName
- Guess whatsignature
- return and argument typespublic int lookupFloat(float n)
n
- Float number to look forpublic int lookupInteger(int n)
n
- integer number to look forpublic int lookupInterfaceMethodref(MethodGen method)
public int lookupInterfaceMethodref(String className, String methodName, String signature)
className
- Where to find methodmethodName
- Guess whatsignature
- return and argument typespublic int lookupLong(long n)
n
- Long number to look forpublic int lookupMethodref(MethodGen method)
public int lookupMethodref(String className, String methodName, String signature)
className
- Where to find methodmethodName
- Guess whatsignature
- return and argument typespublic int lookupNameAndType(String name, String signature)
name
- of variable/methodsignature
- of variable/methodpublic int lookupString(String str)
str
- String to search forpublic int lookupUtf8(String n)
n
- Utf8 string to look forpublic void setConstant(int i, Constant c)
i
- index in constant poolc
- new constant pool entry at index iCopyright © 2004–2024 The Apache Software Foundation. All rights reserved.