|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.curjent.impl.asm.MethodWriter
public final class MethodWriter
A { @link MethodVisitor} that generates methods in bytecode form. Each visit method of this class appends the bytecode corresponding to the visited instruction to a byte vector, in the order these methods are called.
Field Summary | |
---|---|
private int |
access
Access flags of this method. |
private ByteVector |
code
The bytecode of this method. |
private ClassWriter |
cw
The class writer to which this method must be added. |
private int |
desc
The index of the constant pool item that contains the descriptor of this method. |
private int |
exceptionCount
Number of exceptions that can be thrown by this method. |
private int[] |
exceptions
The exceptions that can be thrown by this method. |
private Handler |
firstHandler
The first element in the exception handler list. |
private int |
handlerCount
Number of elements in the exception handler list. |
private Handler |
lastHandler
The last element in the exception handler list. |
private int |
maxLocals
Maximum number of local variables for this method. |
private int |
maxStack
Maximum stack size of this method. |
private int |
name
The index of the constant pool item that contains the name of this method. |
(package private) MethodWriter |
next
Next method writer (see { @link ClassWriter#firstMethod firstMethod}). |
Constructor Summary | |
---|---|
MethodWriter(ClassWriter cw,
int access,
String name,
String desc,
String signature,
String[] exceptions,
boolean computeMaxs,
boolean computeFrames)
Constructs a new { @link MethodWriter}. |
Method Summary | |
---|---|
private static int |
getArgumentsAndReturnSizes(String desc)
Computes the size of the arguments and of the return value of a method. |
(package private) int |
getSize()
Returns the size of the bytecode of this method. |
(package private) void |
put(ByteVector out)
Puts the bytecode of this method in the given byte vector. |
void |
visitCode()
|
void |
visitEnd()
|
void |
visitFieldInsn(int opcode,
String owner,
String name,
String desc)
|
void |
visitInsn(int opcode)
|
void |
visitIntConstInsn(int value)
Pushes an integer constant. |
void |
visitIntInsn(int opcode,
int operand)
|
void |
visitJumpInsn(int opcode,
Label label)
|
void |
visitLabel(Label label)
|
void |
visitLdcInsn(Object cst)
|
void |
visitMaxs(int maxStack,
int maxLocals)
|
void |
visitMethodInsn(int opcode,
String owner,
String name,
String desc)
|
void |
visitReturnInsn(Class<?> returnType)
Calls visitInsn(int) with the JVM opcode for returning a value
based on its type. |
void |
visitTryCatchBlock(Label start,
Label end,
Label handler,
String type)
|
void |
visitTypeInsn(int opcode,
String type)
|
void |
visitVarInsn(int opcode,
int var)
|
void |
visitVarLoadInsn(Class<?> type,
int var)
Calls visitVarInsn(int, int) with the JVM opcode for loading a
value based on its type. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
MethodWriter next
private final ClassWriter cw
private final int access
private final int name
private final int desc
private int exceptionCount
private int[] exceptions
private final ByteVector code
private int maxStack
private int maxLocals
private int handlerCount
private Handler firstHandler
private Handler lastHandler
Constructor Detail |
---|
MethodWriter(ClassWriter cw, int access, String name, String desc, String signature, String[] exceptions, boolean computeMaxs, boolean computeFrames)
cw
- the class writer in which the method must be added.access
- the method's access flags (see { @link Opcodes}).name
- the method's name.desc
- the method's descriptor (see { @link Type}).signature
- the method's signature. May be null.exceptions
- the internal names of the method's exceptions. May be
null.computeMaxs
- true if the maximum stack size and number
of local variables must be automatically computed.computeFrames
- true if the stack map tables must be
recomputed from scratch.Method Detail |
---|
public void visitIntConstInsn(int value)
public void visitVarLoadInsn(Class<?> type, int var)
visitVarInsn(int, int)
with the JVM opcode for loading a
value based on its type. For example, visits ILOAD
for
Boolean.TYPE
.
public void visitReturnInsn(Class<?> returnType)
visitInsn(int)
with the JVM opcode for returning a value
based on its type. For example, visits IRETURN
for
Boolean.TYPE
.
public void visitCode()
public void visitInsn(int opcode)
public void visitIntInsn(int opcode, int operand)
public void visitVarInsn(int opcode, int var)
public void visitTypeInsn(int opcode, String type)
public void visitFieldInsn(int opcode, String owner, String name, String desc)
public void visitMethodInsn(int opcode, String owner, String name, String desc)
public void visitJumpInsn(int opcode, Label label)
public void visitLabel(Label label)
public void visitLdcInsn(Object cst)
public void visitTryCatchBlock(Label start, Label end, Label handler, String type)
public void visitMaxs(int maxStack, int maxLocals)
public void visitEnd()
private static int getArgumentsAndReturnSizes(String desc)
desc
- the descriptor of a method.
int getSize()
void put(ByteVector out)
out
- the byte vector into which the bytecode of this method must be
copied.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |