getCode
public byte[] getCode()
Returns the current bytecode of this method. This bytecode only contains
the instructions: it does not include the Exceptions, LocalVariableTable,
LineNumberTable, Synthetic and Deprecated attributes, if present.
- the current bytecode of this method. The bytecode is contained
between the index 0 (inclusive) and the index
getCodeSize
(exclusive).
getCodeSize
public int getCodeSize()
Returns the current size of the bytecode of this method. This size just
includes the size of the bytecode instructions: it does not include the
size of the Exceptions, LocalVariableTable, LineNumberTable, Synthetic
and Deprecated attributes, if present.
- the current size of the bytecode of this method.
init
protected void init(int access,
String name,
String desc,
String[] exceptions,
Attribute attrs)
Initializes this CodeWriter to define the bytecode of the specified method.
access
- the method's access flags (see Constants
).name
- the method's name.desc
- the method's descriptor (see Type
).exceptions
- the internal names of the method's exceptions. May be
null.attrs
- the non standard attributes of the method.
resizeInstructions
protected int[] resizeInstructions(int[] indexes,
int[] sizes,
int len)
Resizes the designated instructions, while keeping jump offsets and
instruction addresses consistent. This may require to resize other existing
instructions, or even to introduce new instructions: for example,
increasing the size of an instruction by 2 at the middle of a method can
increases the offset of an IFEQ instruction from 32766 to 32768, in which
case IFEQ 32766 must be replaced with IFNEQ 8 GOTO_W 32765. This, in turn,
may require to increase the size of another jump instruction, and so on...
All these operations are handled automatically by this method.
This method must be called after all the method that is being built has
been visited. In particular, the
Label
objects used to
construct the method are no longer valid after this method has been called.
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 getCode
method.len
- the number of instruction to be resized. Must be smaller than or
equal to indexes.length and sizes.length.
- the indexes array, which now contains the new positions of
the resized instructions (designated as above).
visitFieldInsn
public void visitFieldInsn(int opcode,
String owner,
String name,
String desc)
- visitFieldInsn in interface CodeVisitor
visitMethodInsn
public void visitMethodInsn(int opcode,
String owner,
String name,
String desc)
- visitMethodInsn in interface CodeVisitor