public class ConstantPoolGen extends Object implements Serializable
Constant
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected Constant[] |
constants |
protected int |
index |
protected int |
size |
Constructor and Description |
---|
ConstantPoolGen()
Create empty constant pool.
|
ConstantPoolGen(Constant[] cs)
Initialize with given array of constants.
|
ConstantPoolGen(ConstantPool cp)
Initialize with 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 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(String class_name,
String field_name,
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 class_name,
String method_name,
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 class_name,
String method_name,
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 class_name,
String field_name,
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 class_name,
String method_name,
String signature)
Look for ConstantInterfaceMethodref in ConstantPool.
|
int |
lookupLong(long n)
Look for ConstantLong in ConstantPool.
|
int |
lookupMethodref(MethodGen method) |
int |
lookupMethodref(String class_name,
String method_name,
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() |
protected int size
protected Constant[] constants
protected int index
public ConstantPoolGen(Constant[] cs)
cs
- array of given constants, new ones will be appendedpublic ConstantPoolGen(ConstantPool cp)
public ConstantPoolGen()
protected void adjustSize()
public int lookupString(String str)
str
- String to search forpublic int addString(String str)
str
- String to addpublic int lookupClass(String str)
str
- String to search forpublic int addClass(String str)
str
- Class to addpublic int addClass(ObjectType type)
type
- Class to addpublic int addArrayClass(ArrayType type)
type
- type of array classpublic int lookupInteger(int n)
n
- integer number to look forpublic int addInteger(int n)
n
- integer number to addpublic int lookupFloat(float n)
n
- Float number to look forpublic int addFloat(float n)
n
- Float number to addpublic int lookupUtf8(String n)
n
- Utf8 string to look forpublic int addUtf8(String n)
n
- Utf8 string to addpublic int lookupLong(long n)
n
- Long number to look forpublic int addLong(long n)
n
- Long number to addpublic int lookupDouble(double n)
n
- Double number to look forpublic int addDouble(double n)
n
- Double number to addpublic int lookupNameAndType(String name, String signature)
name
- of variable/methodsignature
- of variable/methodpublic int addNameAndType(String name, String signature)
name
- Name string to addsignature
- signature string to addpublic int lookupMethodref(String class_name, String method_name, String signature)
class_name
- Where to find methodmethod_name
- Guess whatsignature
- return and argument typespublic int lookupMethodref(MethodGen method)
public int addMethodref(String class_name, String method_name, String signature)
class_name
- class name string to addmethod_name
- method name string to addsignature
- method signature string to addpublic int addMethodref(MethodGen method)
public int lookupInterfaceMethodref(String class_name, String method_name, String signature)
class_name
- Where to find methodmethod_name
- Guess whatsignature
- return and argument typespublic int lookupInterfaceMethodref(MethodGen method)
public int addInterfaceMethodref(String class_name, String method_name, String signature)
class_name
- class name string to addmethod_name
- method name string to addsignature
- signature string to addpublic int addInterfaceMethodref(MethodGen method)
public int lookupFieldref(String class_name, String field_name, String signature)
class_name
- Where to find methodfield_name
- Guess whatsignature
- return and argument typespublic int addFieldref(String class_name, String field_name, String signature)
class_name
- class name string to addfield_name
- field name string to addsignature
- signature string to addpublic Constant getConstant(int i)
i
- index in constant poolpublic void setConstant(int i, Constant c)
i
- index in constant poolc
- new constant pool entry at index ipublic ConstantPool getConstantPool()
public int getSize()
public ConstantPool getFinalConstantPool()
public String toString()
public int addConstant(Constant c, ConstantPoolGen cp)
Copyright © 2017. All rights reserved.