public class Bytecodes extends Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
Bytecodes.Flags
A collection of flags describing various bytecode attributes.
|
Modifier and Type | Field and Description |
---|---|
static int |
AALOAD |
static int |
AASTORE |
static int |
ACONST_NULL |
static int |
ALOAD |
static int |
ALOAD_0 |
static int |
ALOAD_1 |
static int |
ALOAD_2 |
static int |
ALOAD_3 |
static int |
ANEWARRAY |
static int |
ARETURN |
static int |
ARRAYLENGTH |
static int |
ASTORE |
static int |
ASTORE_0 |
static int |
ASTORE_1 |
static int |
ASTORE_2 |
static int |
ASTORE_3 |
static int |
ATHROW |
static int |
BALOAD |
static int |
BASTORE |
static int |
BIPUSH |
static int |
BREAKPOINT |
static int |
CALOAD |
static int |
CASTORE |
static int |
CHECKCAST |
static int |
D2F |
static int |
D2I |
static int |
D2L |
static int |
DADD |
static int |
DALOAD |
static int |
DASTORE |
static int |
DCMPG |
static int |
DCMPL |
static int |
DCONST_0 |
static int |
DCONST_1 |
static int |
DDIV |
static int |
DLOAD |
static int |
DLOAD_0 |
static int |
DLOAD_1 |
static int |
DLOAD_2 |
static int |
DLOAD_3 |
static int |
DMUL |
static int |
DNEG |
static int |
DREM |
static int |
DRETURN |
static int |
DSTORE |
static int |
DSTORE_0 |
static int |
DSTORE_1 |
static int |
DSTORE_2 |
static int |
DSTORE_3 |
static int |
DSUB |
static int |
DUP |
static int |
DUP_X1 |
static int |
DUP_X2 |
static int |
DUP2 |
static int |
DUP2_X1 |
static int |
DUP2_X2 |
static int |
END |
static int |
F2D |
static int |
F2I |
static int |
F2L |
static int |
FADD |
static int |
FALOAD |
static int |
FASTORE |
static int |
FCMPG |
static int |
FCMPL |
static int |
FCONST_0 |
static int |
FCONST_1 |
static int |
FCONST_2 |
static int |
FDIV |
private static int[] |
flagsArray
An array that maps from a bytecode value to the set of
Bytecodes.Flags for the corresponding
instruction. |
static int |
FLOAD |
static int |
FLOAD_0 |
static int |
FLOAD_1 |
static int |
FLOAD_2 |
static int |
FLOAD_3 |
static int |
FMUL |
static int |
FNEG |
static int |
FREM |
static int |
FRETURN |
static int |
FSTORE |
static int |
FSTORE_0 |
static int |
FSTORE_1 |
static int |
FSTORE_2 |
static int |
FSTORE_3 |
static int |
FSUB |
static int |
GETFIELD |
static int |
GETSTATIC |
static int |
GOTO |
static int |
GOTO_W |
static int |
I2B |
static int |
I2C |
static int |
I2D |
static int |
I2F |
static int |
I2L |
static int |
I2S |
static int |
IADD |
static int |
IALOAD |
static int |
IAND |
static int |
IASTORE |
static int |
ICONST_0 |
static int |
ICONST_1 |
static int |
ICONST_2 |
static int |
ICONST_3 |
static int |
ICONST_4 |
static int |
ICONST_5 |
static int |
ICONST_M1 |
static int |
IDIV |
static int |
IF_ACMPEQ |
static int |
IF_ACMPNE |
static int |
IF_ICMPEQ |
static int |
IF_ICMPGE |
static int |
IF_ICMPGT |
static int |
IF_ICMPLE |
static int |
IF_ICMPLT |
static int |
IF_ICMPNE |
static int |
IFEQ |
static int |
IFGE |
static int |
IFGT |
static int |
IFLE |
static int |
IFLT |
static int |
IFNE |
static int |
IFNONNULL |
static int |
IFNULL |
static int |
IINC |
static int |
ILLEGAL |
static int |
ILOAD |
static int |
ILOAD_0 |
static int |
ILOAD_1 |
static int |
ILOAD_2 |
static int |
ILOAD_3 |
static int |
IMUL |
static int |
INEG |
static int |
INSTANCEOF |
static int |
INVOKEDYNAMIC |
static int |
INVOKEINTERFACE |
static int |
INVOKESPECIAL |
static int |
INVOKESTATIC |
static int |
INVOKEVIRTUAL |
static int |
IOR |
static int |
IREM |
static int |
IRETURN |
static int |
ISHL |
static int |
ISHR |
static int |
ISTORE |
static int |
ISTORE_0 |
static int |
ISTORE_1 |
static int |
ISTORE_2 |
static int |
ISTORE_3 |
static int |
ISUB |
static int |
IUSHR |
static int |
IXOR |
static int |
JSR |
static int |
JSR_W |
static int |
L2D |
static int |
L2F |
static int |
L2I |
static int |
LADD |
static int |
LALOAD |
static int |
LAND |
static int |
LAST_JVM_OPCODE
The last opcode defined by the JVM specification.
|
static int |
LASTORE |
static int |
LCMP |
static int |
LCONST_0 |
static int |
LCONST_1 |
static int |
LDC |
static int |
LDC_W |
static int |
LDC2_W |
static int |
LDIV |
private static int[] |
lengthArray
An array that maps from a bytecode value to the length in bytes for the corresponding
instruction.
|
static int |
LLOAD |
static int |
LLOAD_0 |
static int |
LLOAD_1 |
static int |
LLOAD_2 |
static int |
LLOAD_3 |
static int |
LMUL |
static int |
LNEG |
static int |
LOOKUPSWITCH |
static int |
LOR |
static int |
LREM |
static int |
LRETURN |
static int |
LSHL |
static int |
LSHR |
static int |
LSTORE |
static int |
LSTORE_0 |
static int |
LSTORE_1 |
static int |
LSTORE_2 |
static int |
LSTORE_3 |
static int |
LSUB |
static int |
LUSHR |
static int |
LXOR |
static int |
MONITORENTER |
static int |
MONITOREXIT |
static int |
MULTIANEWARRAY |
private static String[] |
nameArray
An array that maps from a bytecode value to a
String for the corresponding
instruction mnemonic. |
static int |
NEW |
static int |
NEWARRAY |
static int |
NOP |
static int |
POP |
static int |
POP2 |
static int |
PUTFIELD |
static int |
PUTSTATIC |
static int |
RET |
static int |
RETURN |
static int |
SALOAD |
static int |
SASTORE |
static int |
SIPUSH |
private static int[] |
stackEffectArray
An array that maps from a bytecode value to the number of slots pushed on the stack by the
corresponding instruction.
|
static int |
SWAP |
static int |
TABLESWITCH |
static int |
WIDE |
Constructor and Description |
---|
Bytecodes() |
Modifier and Type | Method and Description |
---|---|
static String |
baseNameOf(int opcode)
Allocation-free version of nameOf(int).
|
static boolean |
canTrap(int opcode)
Determines if a given opcode denotes an instruction that can cause an implicit exception.
|
private static void |
def(int opcode,
String name,
String format,
int stackEffect)
Defines a bytecode by entering it into the arrays that record its name, length and flags.
|
private static void |
def(int opcode,
String name,
String format,
int stackEffect,
int flags)
Defines a bytecode by entering it into the arrays that record its name, length and flags.
|
static boolean |
isBlockEnd(int opcode)
Determines if a given opcode is an instruction that delimits a basic block.
|
static boolean |
isBranch(int opcode)
Determines if a given opcode is an instruction that has a 2 or 4 byte operand that is an
offset to another instruction in the same method.
|
static boolean |
isCommutative(int opcode)
Determines if an opcode is commutative.
|
static boolean |
isConditionalBranch(int opcode)
Determines if a given opcode denotes a conditional branch.
|
static boolean |
isInvoke(int opcode)
Determines if a given opcode denotes an instruction that stores a value to a local variable
after popping it from the operand stack.
|
static boolean |
isLoad(int opcode)
Determines if a given opcode denotes an instruction that loads a local variable to the
operand stack.
|
static boolean |
isStop(int opcode)
Determines if a given opcode denotes an instruction that ends a basic block and does not let
control flow fall through to its lexical successor.
|
static boolean |
isStore(int opcode)
Determines if a given opcode denotes an instruction that stores a value to a local variable
after popping it from the operand stack.
|
static int |
lengthOf(int opcode)
Gets the length of an instruction denoted by a given opcode.
|
static String |
nameOf(int opcode)
Gets the lower-case mnemonic for a given opcode.
|
static String |
operator(int op)
Gets the arithmetic operator name for a given opcode.
|
static int |
stackEffectOf(int opcode)
Gets the effect on the depth of the expression stack of an instruction denoted by a given
opcode.
|
static int |
valueOf(String name)
Gets the opcode corresponding to a given mnemonic.
|
public static final int NOP
public static final int ACONST_NULL
public static final int ICONST_M1
public static final int ICONST_0
public static final int ICONST_1
public static final int ICONST_2
public static final int ICONST_3
public static final int ICONST_4
public static final int ICONST_5
public static final int LCONST_0
public static final int LCONST_1
public static final int FCONST_0
public static final int FCONST_1
public static final int FCONST_2
public static final int DCONST_0
public static final int DCONST_1
public static final int BIPUSH
public static final int SIPUSH
public static final int LDC
public static final int LDC_W
public static final int LDC2_W
public static final int ILOAD
public static final int LLOAD
public static final int FLOAD
public static final int DLOAD
public static final int ALOAD
public static final int ILOAD_0
public static final int ILOAD_1
public static final int ILOAD_2
public static final int ILOAD_3
public static final int LLOAD_0
public static final int LLOAD_1
public static final int LLOAD_2
public static final int LLOAD_3
public static final int FLOAD_0
public static final int FLOAD_1
public static final int FLOAD_2
public static final int FLOAD_3
public static final int DLOAD_0
public static final int DLOAD_1
public static final int DLOAD_2
public static final int DLOAD_3
public static final int ALOAD_0
public static final int ALOAD_1
public static final int ALOAD_2
public static final int ALOAD_3
public static final int IALOAD
public static final int LALOAD
public static final int FALOAD
public static final int DALOAD
public static final int AALOAD
public static final int BALOAD
public static final int CALOAD
public static final int SALOAD
public static final int ISTORE
public static final int LSTORE
public static final int FSTORE
public static final int DSTORE
public static final int ASTORE
public static final int ISTORE_0
public static final int ISTORE_1
public static final int ISTORE_2
public static final int ISTORE_3
public static final int LSTORE_0
public static final int LSTORE_1
public static final int LSTORE_2
public static final int LSTORE_3
public static final int FSTORE_0
public static final int FSTORE_1
public static final int FSTORE_2
public static final int FSTORE_3
public static final int DSTORE_0
public static final int DSTORE_1
public static final int DSTORE_2
public static final int DSTORE_3
public static final int ASTORE_0
public static final int ASTORE_1
public static final int ASTORE_2
public static final int ASTORE_3
public static final int IASTORE
public static final int LASTORE
public static final int FASTORE
public static final int DASTORE
public static final int AASTORE
public static final int BASTORE
public static final int CASTORE
public static final int SASTORE
public static final int POP
public static final int POP2
public static final int DUP
public static final int DUP_X1
public static final int DUP_X2
public static final int DUP2
public static final int DUP2_X1
public static final int DUP2_X2
public static final int SWAP
public static final int IADD
public static final int LADD
public static final int FADD
public static final int DADD
public static final int ISUB
public static final int LSUB
public static final int FSUB
public static final int DSUB
public static final int IMUL
public static final int LMUL
public static final int FMUL
public static final int DMUL
public static final int IDIV
public static final int LDIV
public static final int FDIV
public static final int DDIV
public static final int IREM
public static final int LREM
public static final int FREM
public static final int DREM
public static final int INEG
public static final int LNEG
public static final int FNEG
public static final int DNEG
public static final int ISHL
public static final int LSHL
public static final int ISHR
public static final int LSHR
public static final int IUSHR
public static final int LUSHR
public static final int IAND
public static final int LAND
public static final int IOR
public static final int LOR
public static final int IXOR
public static final int LXOR
public static final int IINC
public static final int I2L
public static final int I2F
public static final int I2D
public static final int L2I
public static final int L2F
public static final int L2D
public static final int F2I
public static final int F2L
public static final int F2D
public static final int D2I
public static final int D2L
public static final int D2F
public static final int I2B
public static final int I2C
public static final int I2S
public static final int LCMP
public static final int FCMPL
public static final int FCMPG
public static final int DCMPL
public static final int DCMPG
public static final int IFEQ
public static final int IFNE
public static final int IFLT
public static final int IFGE
public static final int IFGT
public static final int IFLE
public static final int IF_ICMPEQ
public static final int IF_ICMPNE
public static final int IF_ICMPLT
public static final int IF_ICMPGE
public static final int IF_ICMPGT
public static final int IF_ICMPLE
public static final int IF_ACMPEQ
public static final int IF_ACMPNE
public static final int GOTO
public static final int JSR
public static final int RET
public static final int TABLESWITCH
public static final int LOOKUPSWITCH
public static final int IRETURN
public static final int LRETURN
public static final int FRETURN
public static final int DRETURN
public static final int ARETURN
public static final int RETURN
public static final int GETSTATIC
public static final int PUTSTATIC
public static final int GETFIELD
public static final int PUTFIELD
public static final int INVOKEVIRTUAL
public static final int INVOKESPECIAL
public static final int INVOKESTATIC
public static final int INVOKEINTERFACE
public static final int INVOKEDYNAMIC
public static final int NEW
public static final int NEWARRAY
public static final int ANEWARRAY
public static final int ARRAYLENGTH
public static final int ATHROW
public static final int CHECKCAST
public static final int INSTANCEOF
public static final int MONITORENTER
public static final int MONITOREXIT
public static final int WIDE
public static final int MULTIANEWARRAY
public static final int IFNULL
public static final int IFNONNULL
public static final int GOTO_W
public static final int JSR_W
public static final int BREAKPOINT
public static final int ILLEGAL
public static final int END
public static final int LAST_JVM_OPCODE
for (int opcode = 0; opcode <= Bytecodes.LAST_JVM_OPCODE; ++opcode) { // }
private static final String[] nameArray
String
for the corresponding
instruction mnemonic.private static final int[] flagsArray
Bytecodes.Flags
for the corresponding
instruction.private static final int[] lengthArray
private static final int[] stackEffectArray
public Bytecodes()
public static boolean isCommutative(int opcode)
opcode
- the opcode to checktrue
iff commutativepublic static int lengthOf(int opcode)
opcode
- an instruction opcodeopcode
. If opcode
is an
illegal instruction or denotes a variable length instruction (e.g.
TABLESWITCH
), then 0 is returned.public static int stackEffectOf(int opcode)
opcode
- an instruction opcodeopcode
. If
opcode
is an illegal instruction then 0 is returned. Note that invoke
instructions may pop more arguments so this value is a minimum stack effect.public static String nameOf(int opcode) throws IllegalArgumentException
opcode
- an opcodeopcode
or "<illegal opcode: " + opcode + ">"
if
opcode
is not a legal opcodeIllegalArgumentException
public static String baseNameOf(int opcode)
opcode
- an opcode.opcode
or "<illegal opcode>"
if opcode
is
not a legal opcode.public static int valueOf(String name)
name
- an opcode mnemonicmnemonic
IllegalArgumentException
- if name
does not denote a valid opcodepublic static boolean canTrap(int opcode)
opcode
- an opcode to testtrue
iff opcode
can cause an implicit exception, false
otherwisepublic static boolean isLoad(int opcode)
opcode
- an opcode to testtrue
iff opcode
loads a local variable to the operand stack,
false
otherwisepublic static boolean isStop(int opcode)
opcode
- an opcode to testtrue
iff opcode
properly ends a basic blockpublic static boolean isInvoke(int opcode)
opcode
- an opcode to testtrue
iff opcode
stores a value to a local variable, false
otherwisepublic static boolean isStore(int opcode)
opcode
- an opcode to testtrue
iff opcode
stores a value to a local variable, false
otherwisepublic static boolean isBlockEnd(int opcode)
opcode
- an opcode to testtrue
iff opcode
delimits a basic blockpublic static boolean isBranch(int opcode)
opcode
- an opcode to testtrue
iff opcode
is a branch instruction with a single operandpublic static boolean isConditionalBranch(int opcode)
opcode
- true
iff opcode
is a conditional branchpublic static String operator(int op)
opcode
does not denote an
arithmetic instruction, then the name of the opcode is returned
instead.op
- an opcodeprivate static void def(int opcode, String name, String format, int stackEffect)
name
- instruction name (should be lower case)format
- encodes the length of the instructionprivate static void def(int opcode, String name, String format, int stackEffect, int flags)
name
- instruction name (lower case)format
- encodes the length of the instructionflags
- the set of Bytecodes.Flags
associated with the instruction