public final class BytecodeStream extends Object
Bytecodes.WIDE
instruction and wide variants of
instructions internally.Modifier and Type | Field and Description |
---|---|
private byte[] |
code |
private int |
curBCI |
private int |
nextBCI |
private int |
opcode |
Constructor and Description |
---|
BytecodeStream(byte[] code)
Creates a new
BytecodeStream for the specified bytecode. |
Modifier and Type | Method and Description |
---|---|
int |
currentBC()
Gets the current opcode.
|
int |
currentBCI()
Gets the current bytecode index.
|
int |
endBCI()
Gets the bytecode index of the end of the code.
|
private int |
lengthOf()
Gets the length of the current bytecode.
|
void |
next()
Advances to the next bytecode.
|
int |
nextBCI()
Gets the next bytecode index (no side-effects).
|
int |
readBranchDest()
Read the destination of a
Bytecodes.GOTO or IF instructions. |
byte |
readByte()
Reads a signed, 1-byte value for the current instruction (e.g.
|
char |
readCPI()
Reads a constant pool index for the current instruction.
|
int |
readCPI4()
Reads a constant pool index for an invokedynamic instruction.
|
int |
readIncrement()
Read the delta for an
Bytecodes.IINC bytecode. |
int |
readInt(int bci)
Read a signed 4-byte integer from the bytecode stream at the specified bytecode index.
|
int |
readLocalIndex()
Reads the index of a local variable for one of the load or store instructions.
|
short |
readShort()
Reads a signed, 2-byte short for the current instruction (e.g.
|
int |
readUByte(int bci)
Reads an unsigned, 1-byte value from the bytecode stream at the specified bytecode index.
|
void |
setBCI(int bci)
Sets the bytecode index to the specified value.
|
private final byte[] code
private int opcode
private int curBCI
private int nextBCI
public BytecodeStream(byte[] code)
BytecodeStream
for the specified bytecode.code
- the array of bytes that contains the bytecodepublic void next()
public int nextBCI()
public int currentBCI()
public int endBCI()
public int currentBC()
WIDE
opcode, but will instead return the opcode that is modified by the WIDE
opcode.Bytecodes.END
if at or beyond the end of the codepublic int readLocalIndex()
public int readIncrement()
Bytecodes.IINC
bytecode.IINC
public int readBranchDest()
Bytecodes.GOTO
or IF
instructions.public int readInt(int bci)
bci
- the bytecode indexpublic int readUByte(int bci)
bci
- the bytecode indexpublic char readCPI()
public int readCPI4()
public byte readByte()
public short readShort()
public void setBCI(int bci)
bci
is beyond the end of the
array, currentBC()
will return Bytecodes.END
and other methods may throw
ArrayIndexOutOfBoundsException
.bci
- the new bytecode indexprivate int lengthOf()