org.objectweb.asm
public class CodeWriter extends Object implements CodeVisitor
Constructor Summary | |
---|---|
protected | CodeWriter(ClassWriter cw, boolean computeMaxs)
Constructs a CodeWriter.
|
Method Summary | |
---|---|
byte[] | getCode()
Returns the current bytecode of this method. |
int | getCodeSize()
Returns the current size of the bytecode of this method. |
protected void | init(int access, String name, String desc, String[] exceptions, Attribute attrs)
Initializes this CodeWriter to define the bytecode of the specified method.
|
protected int[] | resizeInstructions(int[] indexes, int[] sizes, int len)
Resizes the designated instructions, while keeping jump offsets and
instruction addresses consistent. |
void | visitAttribute(Attribute attr) |
void | visitFieldInsn(int opcode, String owner, String name, String desc) |
void | visitIincInsn(int var, int increment) |
void | visitInsn(int opcode) |
void | visitIntInsn(int opcode, int operand) |
void | visitJumpInsn(int opcode, Label label) |
void | visitLabel(Label label) |
void | visitLdcInsn(Object cst) |
void | visitLineNumber(int line, Label start) |
void | visitLocalVariable(String name, String desc, Label start, Label end, int index) |
void | visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) |
void | visitMaxs(int maxStack, int maxLocals) |
void | visitMethodInsn(int opcode, String owner, String name, String desc) |
void | visitMultiANewArrayInsn(String desc, int dims) |
void | visitTableSwitchInsn(int min, int max, Label dflt, Label[] labels) |
void | visitTryCatchBlock(Label start, Label end, Label handler, String type) |
void | visitTypeInsn(int opcode, String desc) |
void | visitVarInsn(int opcode, int var) |
Parameters: cw the class writer in which the method must be added. computeMaxs true if the maximum stack size and number of local variables must be automatically computed.
Returns: the current bytecode of this method. The bytecode is contained between the index 0 (inclusive) and the index {@link #getCodeSize getCodeSize} (exclusive).
Returns: the current size of the bytecode of this method.
Parameters: access the method's access flags (see {@link Constants}). name the method's name. desc the method's descriptor (see {@link Type Type}). exceptions the internal names of the method's exceptions. May be null. attrs the non standard attributes of the method.
This method must be called after all the method that is being built has been visited. In particular, the {@link Label Label} objects used to construct the method are no longer valid after this method has been called.
Parameters: indexes current positions of the instructions to be resized. Each instruction must be designated by the index of its last byte, plus one (or, in other words, by the index of the first byte of the next instruction). sizes the number of bytes to be added to the above instructions. More precisely, for each i < len, sizes[i] bytes will be added at the end of the instruction designated by indexes[i] or, if sizes[i] is negative, the last |sizes[i]| bytes of the instruction will be removed (the instruction size must not become negative or null). The gaps introduced by this method must be filled in "manually" in the array returned by the {@link #getCode getCode} method. len the number of instruction to be resized. Must be smaller than or equal to indexes.length and sizes.length.
Returns: the indexes array, which now contains the new positions of the resized instructions (designated as above).