|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.curjent.impl.asm.ClassWriter
public final class ClassWriter
A { @link ClassVisitor} that generates classes in bytecode form. More precisely this visitor generates a byte array conforming to the Java class file format. It can be used alone, to generate a Java class "from scratch", or with one or more { @link ClassReader ClassReader} and adapter class visitor to generate a modified class from one or more existing Java classes.
Field Summary | |
---|---|
private int |
access
The access flags of this class. |
(package private) static int |
CLASS
The type of CONSTANT_Class constant pool items. |
(package private) static int |
DOUBLE
The type of CONSTANT_Double constant pool items. |
(package private) static int |
FIELD
The type of CONSTANT_Fieldref constant pool items. |
(package private) FieldWriter |
firstField
The fields of this class. |
(package private) MethodWriter |
firstMethod
The methods of this class. |
(package private) static int |
FLOAT
The type of CONSTANT_Float constant pool items. |
(package private) static int |
IMETH
The type of CONSTANT_InterfaceMethodref constant pool items. |
private int |
index
Index of the next item to be added in the constant pool. |
(package private) static int |
INT
The type of CONSTANT_Integer constant pool items. |
private int |
interfaceCount
Number of interfaces implemented or extended by this class or interface. |
private int[] |
interfaces
The interfaces implemented or extended by this class or interface. |
private Item[] |
items
The constant pool's hash table data. |
private Item |
key
A reusable key used to look for items in the { @link #items} hash table. |
private Item |
key2
A reusable key used to look for items in the { @link #items} hash table. |
private Item |
key3
A reusable key used to look for items in the { @link #items} hash table. |
(package private) FieldWriter |
lastField
The fields of this class. |
(package private) MethodWriter |
lastMethod
The methods of this class. |
(package private) static int |
LONG
The type of CONSTANT_Long constant pool items. |
(package private) static int |
METH
The type of CONSTANT_Methodref constant pool items. |
private int |
name
The constant pool item that contains the internal name of this class. |
(package private) static int |
NAME_TYPE
The type of CONSTANT_NameAndType constant pool items. |
private ByteVector |
pool
The constant pool of this class. |
(package private) static int |
STR
The type of CONSTANT_String constant pool items. |
private int |
superName
The constant pool item that contains the internal name of the super class of this class. |
private int |
threshold
The threshold of the constant pool's hash table. |
(package private) static int |
TYPE_MERGED
Merged type Item stored in the ClassWriter { @link ClassWriter#typeTable}, instead of the constant pool, in order to avoid clashes with normal constant pool items in the ClassWriter constant pool's hash table. |
(package private) static int |
TYPE_NORMAL
Normal type Item stored in the ClassWriter { @link ClassWriter#typeTable}, instead of the constant pool, in order to avoid clashes with normal constant pool items in the ClassWriter constant pool's hash table. |
(package private) static int |
TYPE_UNINIT
Uninitialized type Item stored in the ClassWriter { @link ClassWriter#typeTable}, instead of the constant pool, in order to avoid clashes with normal constant pool items in the ClassWriter constant pool's hash table. |
(package private) static int |
UTF8
The type of CONSTANT_Utf8 constant pool items. |
private int |
version
Minor and major version numbers of the class to be generated. |
Constructor Summary | |
---|---|
ClassWriter(int flags)
Constructs a new { @link ClassWriter} object. |
Method Summary | |
---|---|
private Item |
get(Item key)
Returns the constant pool's hash table item which is equal to the given item. |
(package private) int |
newClass(String value)
Adds a class reference to the constant pool of the class being build. |
(package private) Item |
newClassItem(String value)
Adds a class reference to the constant pool of the class being build. |
(package private) Item |
newConstItem(Object cst)
Adds a number or string constant to the constant pool of the class being build. |
(package private) Item |
newDouble(double value)
Adds a double to the constant pool of the class being build. |
(package private) Item |
newFieldItem(String owner,
String name,
String desc)
Adds a field reference to the constant pool of the class being build. |
(package private) Item |
newFloat(float value)
Adds a float to the constant pool of the class being build. |
(package private) Item |
newInteger(int value)
Adds an integer to the constant pool of the class being build. |
(package private) Item |
newLong(long value)
Adds a long to the constant pool of the class being build. |
(package private) Item |
newMethodItem(String owner,
String name,
String desc,
boolean itf)
Adds a method reference to the constant pool of the class being build. |
private int |
newNameType(String name,
String desc)
Adds a name and type to the constant pool of the class being build. |
private Item |
newString(String value)
Adds a string to the constant pool of the class being build. |
(package private) int |
newUTF8(String value)
Adds an UTF8 string to the constant pool of the class being build. |
private void |
put(Item i)
Puts the given item in the constant pool's hash table. |
private void |
put122(int b,
int s1,
int s2)
Puts one byte and two shorts into the constant pool. |
byte[] |
toByteArray()
Returns the bytecode of the class that was build with this class writer. |
void |
visit(int version,
int access,
String name,
String signature,
String superName,
String[] interfaces)
|
void |
visitEnd()
|
FieldWriter |
visitField(int access,
String name,
String desc,
String signature,
Object value)
|
MethodWriter |
visitMethod(int access,
String name,
String desc,
String signature,
String[] exceptions)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static final int CLASS
static final int FIELD
static final int METH
static final int IMETH
static final int STR
static final int INT
static final int FLOAT
static final int LONG
static final int DOUBLE
static final int NAME_TYPE
static final int UTF8
static final int TYPE_NORMAL
static final int TYPE_UNINIT
static final int TYPE_MERGED
private int version
private int index
private final ByteVector pool
private Item[] items
private int threshold
private final Item key
private final Item key2
private final Item key3
private int access
private int name
private int superName
private int interfaceCount
private int[] interfaces
FieldWriter firstField
FieldWriter lastField
MethodWriter firstMethod
MethodWriter lastMethod
Constructor Detail |
---|
public ClassWriter(int flags)
flags
- option flags that can be used to modify the default behavior
of this class. See { @link #COMPUTE_MAXS}, { @link #COMPUTE_FRAMES}.Method Detail |
---|
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces)
public FieldWriter visitField(int access, String name, String desc, String signature, Object value)
public MethodWriter visitMethod(int access, String name, String desc, String signature, String[] exceptions)
public void visitEnd()
public byte[] toByteArray()
Item newConstItem(Object cst)
cst
- the value of the constant to be added to the constant pool.
This parameter must be an { @link Integer}, a { @link Float}, a
{ @link Long}, a { @link Double}, a { @link String} or a
{ @link Type}.
int newUTF8(String value)
value
- the String value.
Item newClassItem(String value)
value
- the internal name of the class.
int newClass(String value)
value
- the internal name of the class.
Item newFieldItem(String owner, String name, String desc)
owner
- the internal name of the field's owner class.name
- the field's name.desc
- the field's descriptor.
Item newMethodItem(String owner, String name, String desc, boolean itf)
owner
- the internal name of the method's owner class.name
- the method's name.desc
- the method's descriptor.itf
- true if owner is an interface.
Item newInteger(int value)
value
- the int value.
Item newFloat(float value)
value
- the float value.
Item newLong(long value)
value
- the long value.
Item newDouble(double value)
value
- the double value.
private Item newString(String value)
value
- the String value.
private int newNameType(String name, String desc)
name
- a name.desc
- a type descriptor.
private Item get(Item key)
key
- a constant pool item.
private void put(Item i)
i
- the item to be added to the constant pool's hash table.private void put122(int b, int s1, int s2)
b
- a byte.s1
- a short.s2
- another short.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |