public static final class ClassFileWriter.MethodWriter
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private int |
catchCount |
private int |
catchPos |
protected int |
codeIndex |
protected ClassFileWriter.ConstPoolWriter |
constPool |
private boolean |
isAbstract |
private int |
methodCount |
protected ByteStream |
output |
protected int |
stackIndex |
private int |
startPos |
protected int |
throwsIndex |
Constructor and Description |
---|
MethodWriter(ClassFileWriter.ConstPoolWriter cp) |
Modifier and Type | Method and Description |
---|---|
void |
add(int b)
Appends an 8bit value of bytecode.
|
void |
add16(int b)
Appends a 16bit value of bytecode.
|
void |
add32(int b)
Appends a 32bit value of bytecode.
|
void |
addCatch(int startPc,
int endPc,
int handlerPc,
int catchType)
Appends an
exception_table entry to the
Code_attribute . |
void |
addInvoke(int opcode,
java.lang.String targetClass,
java.lang.String methodName,
java.lang.String descriptor)
Appends a invokevirtual, inovkespecial, or invokestatic bytecode.
|
void |
begin(int accessFlags,
int name,
int descriptor,
int[] exceptions,
ClassFileWriter.AttributeWriter aw)
Starts adding a new method.
|
void |
begin(int accessFlags,
java.lang.String name,
java.lang.String descriptor,
java.lang.String[] exceptions,
ClassFileWriter.AttributeWriter aw)
Starts Adding a new method.
|
void |
codeEnd(int maxStack,
int maxLocals)
Ends appending bytecode.
|
(package private) int |
dataSize() |
void |
end(StackMapTable.Writer smap,
ClassFileWriter.AttributeWriter aw)
Ends adding a new method.
|
(package private) int |
size() |
(package private) void |
write(java.io.OutputStream out)
Writes the added methods.
|
private void |
writeThrows(int[] exceptions) |
protected ByteStream output
protected ClassFileWriter.ConstPoolWriter constPool
private int methodCount
protected int codeIndex
protected int throwsIndex
protected int stackIndex
private int startPos
private boolean isAbstract
private int catchPos
private int catchCount
MethodWriter(ClassFileWriter.ConstPoolWriter cp)
public void begin(int accessFlags, java.lang.String name, java.lang.String descriptor, java.lang.String[] exceptions, ClassFileWriter.AttributeWriter aw)
accessFlags
- access flags.name
- the method name.descriptor
- the method signature.exceptions
- throws clause. It may be null.
The class names must be the JVM-internal
representations like java/lang/Exception
.aw
- attributes to the Method_info
.public void begin(int accessFlags, int name, int descriptor, int[] exceptions, ClassFileWriter.AttributeWriter aw)
accessFlags
- access flags.name
- the method name. an index indicating its CONSTANT_Utf8_info
.descriptor
- the field type. an index indicating its CONSTANT_Utf8_info
.exceptions
- throws clause. indexes indicating CONSTANT_Class_info
s.
It may be null.aw
- attributes to the Method_info
.private void writeThrows(int[] exceptions)
public void add(int b)
Opcode
public void add16(int b)
public void add32(int b)
public void addInvoke(int opcode, java.lang.String targetClass, java.lang.String methodName, java.lang.String descriptor)
Opcode
public void codeEnd(int maxStack, int maxLocals)
public void addCatch(int startPc, int endPc, int handlerPc, int catchType)
exception_table
entry to the
Code_attribute
. This method is available
only after the codeEnd
method is called.catchType
- an index indicating a CONSTANT_Class_info
.public void end(StackMapTable.Writer smap, ClassFileWriter.AttributeWriter aw)
add
method must be
called before the end
method is called.smap
- a stack map table. may be null.aw
- attributes to the Code_attribute
.
may be null.int size()
int dataSize()
void write(java.io.OutputStream out) throws java.io.IOException
java.io.IOException