public final class MethodWriter
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private int |
accessFlags |
private ByteVector |
code
The 'code' field of the Code attribute.
|
private Label |
currentBasicBlock |
private int[] |
currentFrame |
private java.lang.String |
descriptor
The descriptor of this method.
|
private int |
descriptorIndex
The descriptor_index field of the method_info JVMS structure.
|
private Label |
firstBasicBlock
The first basic block of the method.
|
(package private) boolean |
hasAsmInstructions |
private Label |
lastBasicBlock
The last basic block of the method (in bytecode offset order).
|
private int |
lastBytecodeOffset
The start offset of the last visited instruction.
|
private int |
maxLocals
The max_locals field of the Code attribute.
|
private int |
maxStack
The max_stack field of the Code attribute.
|
(package private) MethodWriter |
mv |
private java.lang.String |
name
The name of this method.
|
private int |
nameIndex
The name_index field of the method_info JVMS structure.
|
private int[] |
previousFrame
The last frame that was written in
stackMapTableEntries. |
private ByteVector |
stackMapTableEntries
The 'entries' array of the StackMapTable code attribute.
|
(package private) int |
stackMapTableNumberOfEntries
The number_of_entries field of the StackMapTable code attribute.
|
private SymbolTable |
symbolTable
Where the constants used in this MethodWriter must be stored.
|
| Constructor and Description |
|---|
MethodWriter(SymbolTable symbolTable,
int access,
java.lang.String name,
java.lang.String descriptor,
int codeInitCapacity)
Constructs a new
MethodWriter. |
| Modifier and Type | Method and Description |
|---|---|
void |
aaload() |
void |
aastore() |
void |
aconst_null() |
private void |
addSuccessorToCurrentBasicBlock(Label successor)
Adds a successor to
currentBasicBlock in the control flow graph. |
void |
aload(int var) |
void |
anewArray(java.lang.String type) |
void |
areturn() |
void |
arraylength() |
void |
astore(int var) |
void |
bastore() |
void |
bipush(int operand) |
void |
castore() |
void |
checkcast(java.lang.String type) |
void |
cmpWithZero(java.lang.Class<?> fieldClass) |
(package private) int |
computeMethodInfoSize()
Returns the size of the method_info JVMS structure generated by this MethodWriter.
|
void |
dstore(int var) |
void |
dup() |
void |
dup(java.lang.Class<?> fieldClass) |
void |
dup2() |
private void |
endCurrentBasicBlockWithNoSuccessor()
Ends the current basic block.
|
void |
fstore(int var) |
void |
getfield(java.lang.String owner,
java.lang.String name,
java.lang.String descriptor) |
void |
getstatic(java.lang.String owner,
java.lang.String name,
java.lang.String descriptor) |
void |
goto_(Label label) |
void |
i2d() |
void |
i2f() |
void |
i2l() |
void |
iadd() |
void |
iconst_0() |
void |
iconst_1() |
void |
iconst_2() |
void |
iconst_3() |
void |
iconst_4() |
void |
iconst_5() |
void |
iconst_m1() |
void |
iconst_n(int n) |
void |
if_acmpeq(Label label) |
void |
if_acmpne(Label label) |
void |
if_icmpeq(Label label) |
void |
if_icmpge(Label label) |
void |
if_icmple(Label label) |
void |
if_icmpne(Label label) |
void |
ifeq(Label label) |
void |
ifge(Label label) |
void |
ifne(Label label) |
void |
ifnonnull(Label label) |
void |
ifnull(Label label) |
void |
iload(int var) |
void |
imul() |
void |
ineg() |
void |
instanceOf(java.lang.String type) |
void |
invokeinterface(java.lang.String owner,
java.lang.String name,
java.lang.String descriptor) |
void |
invokespecial(java.lang.String owner,
java.lang.String name,
java.lang.String descriptor) |
void |
invokestatic(java.lang.String owner,
java.lang.String name,
java.lang.String descriptor) |
void |
invokestatic(java.lang.String owner,
java.lang.String name,
java.lang.String descriptor,
boolean isInterface) |
void |
invokevirtual(java.lang.String owner,
java.lang.String name,
java.lang.String descriptor) |
void |
ireturn() |
void |
istore(int var) |
void |
isub() |
void |
ixor() |
void |
l2i() |
void |
land() |
void |
lcmp() |
void |
lconst_0() |
void |
lload(int var) |
void |
loadLocal(java.lang.Class<?> cls,
int var) |
void |
lor() |
void |
lstore(int var) |
void |
lushr() |
void |
lxor() |
void |
new_(java.lang.String type) |
void |
pop() |
private void |
putAbstractTypes(int start,
int end)
Puts some abstract types of
currentFrame in stackMapTableEntries , using the
JVMS verification_type_info format used in StackMapTable attributes. |
void |
putfield(java.lang.String owner,
java.lang.String name,
java.lang.String descriptor) |
private void |
putFrame()
Compresses and writes
currentFrame in a new StackMapTable entry. |
(package private) void |
putMethodInfo(ByteVector output)
Puts the content of the method_info JVMS structure generated by this MethodWriter into the
given ByteVector.
|
void |
return_() |
void |
sipush(int operand) |
void |
storeLocal(java.lang.Class<?> cls,
int var) |
void |
swap() |
(package private) void |
visitAbstractType(int frameIndex,
int abstractType)
Sets an abstract type in
currentFrame. |
private void |
visitFieldInsn(int opcode,
java.lang.String owner,
java.lang.String name,
java.lang.String descriptor) |
(package private) void |
visitFrameEnd()
Ends the visit of
currentFrame by writing it in the StackMapTable entries and by
updating the StackMapTable number_of_entries (except if the current frame is the first one,
which is implicit in StackMapTable). |
(package private) int |
visitFrameStart(int offset,
int numLocal,
int numStack)
Starts the visit of a new stack map frame, stored in
currentFrame. |
void |
visitIincInsn(int var,
int increment) |
private void |
visitInsn(int opcode) |
private void |
visitIntInsn(int opcode,
int operand) |
private void |
visitJumpInsn(int opcode,
Label label) |
void |
visitLabel(Label label) |
void |
visitLdcInsn(java.lang.Class value) |
void |
visitLdcInsn(int value) |
void |
visitLdcInsn(long value) |
void |
visitLdcInsn(java.lang.Number value) |
void |
visitLdcInsn(java.lang.String value) |
void |
visitLookupSwitchInsn(Label dflt,
int[] keys,
Label[] labels) |
void |
visitMaxs(int maxStack,
int maxLocals) |
private void |
visitMethodInsn(int opcode,
java.lang.String owner,
java.lang.String name,
java.lang.String descriptor,
boolean isInterface) |
private void |
visitSwitchInsn(Label dflt,
Label[] labels) |
private void |
visitTypeInsn(int opcode,
java.lang.String type) |
void |
visitVarInsn(int opcode,
int var) |
MethodWriter mv
private final SymbolTable symbolTable
private final int accessFlags
private final int nameIndex
private final java.lang.String name
private final int descriptorIndex
private final java.lang.String descriptor
private int maxStack
private int maxLocals
private final ByteVector code
int stackMapTableNumberOfEntries
private ByteVector stackMapTableEntries
private final Label firstBasicBlock
Label.nextBasicBlock field.private Label lastBasicBlock
private Label currentBasicBlock
private int[] previousFrame
stackMapTableEntries. This field has the same
format as currentFrame.private int[] currentFrame
boolean hasAsmInstructions
private int lastBytecodeOffset
MethodWriter(SymbolTable symbolTable, int access, java.lang.String name, java.lang.String descriptor, int codeInitCapacity)
MethodWriter.public void return_()
public void ireturn()
public void areturn()
public void iconst_0()
public void iconst_1()
public void iconst_2()
public void iconst_3()
public void iconst_4()
public void iconst_5()
public void iconst_n(int n)
public void iconst_m1()
public void lconst_0()
public void lcmp()
public void land()
public void iadd()
public void isub()
public void imul()
public void bastore()
public void castore()
public void aconst_null()
public void ixor()
public void ineg()
public void lor()
public void swap()
public void arraylength()
public void l2i()
public void i2l()
public void i2f()
public void i2d()
public void cmpWithZero(java.lang.Class<?> fieldClass)
public void lxor()
public void lushr()
public void aaload()
public void aastore()
private void visitInsn(int opcode)
public void sipush(int operand)
public void bipush(int operand)
private void visitIntInsn(int opcode,
int operand)
public void loadLocal(java.lang.Class<?> cls,
int var)
public void storeLocal(java.lang.Class<?> cls,
int var)
public void aload(int var)
public void astore(int var)
public void iload(int var)
public void istore(int var)
public void lload(int var)
public void lstore(int var)
public void fstore(int var)
public void dstore(int var)
public void dup()
public void dup(java.lang.Class<?> fieldClass)
public void dup2()
public void pop()
public void visitVarInsn(int opcode,
int var)
public void checkcast(java.lang.String type)
public void new_(java.lang.String type)
public void anewArray(java.lang.String type)
public void instanceOf(java.lang.String type)
private void visitTypeInsn(int opcode,
java.lang.String type)
public void getfield(java.lang.String owner,
java.lang.String name,
java.lang.String descriptor)
public void putfield(java.lang.String owner,
java.lang.String name,
java.lang.String descriptor)
public void getstatic(java.lang.String owner,
java.lang.String name,
java.lang.String descriptor)
private void visitFieldInsn(int opcode,
java.lang.String owner,
java.lang.String name,
java.lang.String descriptor)
public void invokestatic(java.lang.String owner,
java.lang.String name,
java.lang.String descriptor)
public void invokestatic(java.lang.String owner,
java.lang.String name,
java.lang.String descriptor,
boolean isInterface)
public void invokevirtual(java.lang.String owner,
java.lang.String name,
java.lang.String descriptor)
public void invokeinterface(java.lang.String owner,
java.lang.String name,
java.lang.String descriptor)
public void invokespecial(java.lang.String owner,
java.lang.String name,
java.lang.String descriptor)
private void visitMethodInsn(int opcode,
java.lang.String owner,
java.lang.String name,
java.lang.String descriptor,
boolean isInterface)
public void ifeq(Label label)
public void ifne(Label label)
public void ifge(Label label)
public void ifnull(Label label)
public void if_icmpeq(Label label)
public void if_acmpeq(Label label)
public void if_acmpne(Label label)
public void goto_(Label label)
public void ifnonnull(Label label)
public void if_icmpge(Label label)
public void if_icmple(Label label)
public void if_icmpne(Label label)
private void visitJumpInsn(int opcode,
Label label)
public void visitLabel(Label label)
public void visitLdcInsn(java.lang.String value)
public void visitLdcInsn(java.lang.Class value)
public void visitLdcInsn(java.lang.Number value)
public void visitLdcInsn(int value)
public void visitLdcInsn(long value)
public void visitIincInsn(int var,
int increment)
public void visitMaxs(int maxStack,
int maxLocals)
private void addSuccessorToCurrentBasicBlock(Label successor)
currentBasicBlock in the control flow graph.successor - the successor block to be added to the current basic block.private void endCurrentBasicBlockWithNoSuccessor()
WARNING: this method must be called after the currently visited instruction has been put in
code (if frames are computed, this method inserts a new Label to start a new basic
block after the current instruction).
int visitFrameStart(int offset,
int numLocal,
int numStack)
currentFrame.offset - the bytecode offset of the instruction to which the frame corresponds.numLocal - the number of local variables in the frame.numStack - the number of stack elements in the frame.void visitAbstractType(int frameIndex,
int abstractType)
currentFrame.frameIndex - the index of the element to be set in currentFrame.abstractType - an abstract type.void visitFrameEnd()
currentFrame by writing it in the StackMapTable entries and by
updating the StackMapTable number_of_entries (except if the current frame is the first one,
which is implicit in StackMapTable). Then resets currentFrame to null.private void putFrame()
currentFrame in a new StackMapTable entry.private void putAbstractTypes(int start,
int end)
currentFrame in stackMapTableEntries , using the
JVMS verification_type_info format used in StackMapTable attributes.start - index of the first type in currentFrame to write.end - index of last type in currentFrame to write (exclusive).int computeMethodInfoSize()
void putMethodInfo(ByteVector output)
output - where the method_info structure must be put.