FileDocCategorySizeDatePackage
Opcodes.javaAPI DocAndroid 5.1 API14669Thu Mar 12 22:18:30 GMT 2015com.android.dx.io

Opcodes

public final class Opcodes extends Object
All the Dalvik opcode value constants. See the related spec document for the meaning and instruction format of each opcode.

Fields Summary
public static final int
SPECIAL_FORMAT
pseudo-opcode used for nonstandard format payload "instructions". TODO: Retire this concept, and start treating the payload instructions more like the rest.
public static final int
NO_NEXT
pseudo-opcode used to indicate there is no next opcode; used in opcode chaining lists
public static final int
MIN_VALUE
minimum valid opcode value
public static final int
MAX_VALUE
maximum valid opcode value
public static final int
NOP
public static final int
MOVE
public static final int
MOVE_FROM16
public static final int
MOVE_16
public static final int
MOVE_WIDE
public static final int
MOVE_WIDE_FROM16
public static final int
MOVE_WIDE_16
public static final int
MOVE_OBJECT
public static final int
MOVE_OBJECT_FROM16
public static final int
MOVE_OBJECT_16
public static final int
MOVE_RESULT
public static final int
MOVE_RESULT_WIDE
public static final int
MOVE_RESULT_OBJECT
public static final int
MOVE_EXCEPTION
public static final int
RETURN_VOID
public static final int
RETURN
public static final int
RETURN_WIDE
public static final int
RETURN_OBJECT
public static final int
CONST_4
public static final int
CONST_16
public static final int
CONST
public static final int
CONST_HIGH16
public static final int
CONST_WIDE_16
public static final int
CONST_WIDE_32
public static final int
CONST_WIDE
public static final int
CONST_WIDE_HIGH16
public static final int
CONST_STRING
public static final int
CONST_STRING_JUMBO
public static final int
CONST_CLASS
public static final int
MONITOR_ENTER
public static final int
MONITOR_EXIT
public static final int
CHECK_CAST
public static final int
INSTANCE_OF
public static final int
ARRAY_LENGTH
public static final int
NEW_INSTANCE
public static final int
NEW_ARRAY
public static final int
FILLED_NEW_ARRAY
public static final int
FILLED_NEW_ARRAY_RANGE
public static final int
FILL_ARRAY_DATA
public static final int
THROW
public static final int
GOTO
public static final int
GOTO_16
public static final int
GOTO_32
public static final int
PACKED_SWITCH
public static final int
SPARSE_SWITCH
public static final int
CMPL_FLOAT
public static final int
CMPG_FLOAT
public static final int
CMPL_DOUBLE
public static final int
CMPG_DOUBLE
public static final int
CMP_LONG
public static final int
IF_EQ
public static final int
IF_NE
public static final int
IF_LT
public static final int
IF_GE
public static final int
IF_GT
public static final int
IF_LE
public static final int
IF_EQZ
public static final int
IF_NEZ
public static final int
IF_LTZ
public static final int
IF_GEZ
public static final int
IF_GTZ
public static final int
IF_LEZ
public static final int
AGET
public static final int
AGET_WIDE
public static final int
AGET_OBJECT
public static final int
AGET_BOOLEAN
public static final int
AGET_BYTE
public static final int
AGET_CHAR
public static final int
AGET_SHORT
public static final int
APUT
public static final int
APUT_WIDE
public static final int
APUT_OBJECT
public static final int
APUT_BOOLEAN
public static final int
APUT_BYTE
public static final int
APUT_CHAR
public static final int
APUT_SHORT
public static final int
IGET
public static final int
IGET_WIDE
public static final int
IGET_OBJECT
public static final int
IGET_BOOLEAN
public static final int
IGET_BYTE
public static final int
IGET_CHAR
public static final int
IGET_SHORT
public static final int
IPUT
public static final int
IPUT_WIDE
public static final int
IPUT_OBJECT
public static final int
IPUT_BOOLEAN
public static final int
IPUT_BYTE
public static final int
IPUT_CHAR
public static final int
IPUT_SHORT
public static final int
SGET
public static final int
SGET_WIDE
public static final int
SGET_OBJECT
public static final int
SGET_BOOLEAN
public static final int
SGET_BYTE
public static final int
SGET_CHAR
public static final int
SGET_SHORT
public static final int
SPUT
public static final int
SPUT_WIDE
public static final int
SPUT_OBJECT
public static final int
SPUT_BOOLEAN
public static final int
SPUT_BYTE
public static final int
SPUT_CHAR
public static final int
SPUT_SHORT
public static final int
INVOKE_VIRTUAL
public static final int
INVOKE_SUPER
public static final int
INVOKE_DIRECT
public static final int
INVOKE_STATIC
public static final int
INVOKE_INTERFACE
public static final int
INVOKE_VIRTUAL_RANGE
public static final int
INVOKE_SUPER_RANGE
public static final int
INVOKE_DIRECT_RANGE
public static final int
INVOKE_STATIC_RANGE
public static final int
INVOKE_INTERFACE_RANGE
public static final int
NEG_INT
public static final int
NOT_INT
public static final int
NEG_LONG
public static final int
NOT_LONG
public static final int
NEG_FLOAT
public static final int
NEG_DOUBLE
public static final int
INT_TO_LONG
public static final int
INT_TO_FLOAT
public static final int
INT_TO_DOUBLE
public static final int
LONG_TO_INT
public static final int
LONG_TO_FLOAT
public static final int
LONG_TO_DOUBLE
public static final int
FLOAT_TO_INT
public static final int
FLOAT_TO_LONG
public static final int
FLOAT_TO_DOUBLE
public static final int
DOUBLE_TO_INT
public static final int
DOUBLE_TO_LONG
public static final int
DOUBLE_TO_FLOAT
public static final int
INT_TO_BYTE
public static final int
INT_TO_CHAR
public static final int
INT_TO_SHORT
public static final int
ADD_INT
public static final int
SUB_INT
public static final int
MUL_INT
public static final int
DIV_INT
public static final int
REM_INT
public static final int
AND_INT
public static final int
OR_INT
public static final int
XOR_INT
public static final int
SHL_INT
public static final int
SHR_INT
public static final int
USHR_INT
public static final int
ADD_LONG
public static final int
SUB_LONG
public static final int
MUL_LONG
public static final int
DIV_LONG
public static final int
REM_LONG
public static final int
AND_LONG
public static final int
OR_LONG
public static final int
XOR_LONG
public static final int
SHL_LONG
public static final int
SHR_LONG
public static final int
USHR_LONG
public static final int
ADD_FLOAT
public static final int
SUB_FLOAT
public static final int
MUL_FLOAT
public static final int
DIV_FLOAT
public static final int
REM_FLOAT
public static final int
ADD_DOUBLE
public static final int
SUB_DOUBLE
public static final int
MUL_DOUBLE
public static final int
DIV_DOUBLE
public static final int
REM_DOUBLE
public static final int
ADD_INT_2ADDR
public static final int
SUB_INT_2ADDR
public static final int
MUL_INT_2ADDR
public static final int
DIV_INT_2ADDR
public static final int
REM_INT_2ADDR
public static final int
AND_INT_2ADDR
public static final int
OR_INT_2ADDR
public static final int
XOR_INT_2ADDR
public static final int
SHL_INT_2ADDR
public static final int
SHR_INT_2ADDR
public static final int
USHR_INT_2ADDR
public static final int
ADD_LONG_2ADDR
public static final int
SUB_LONG_2ADDR
public static final int
MUL_LONG_2ADDR
public static final int
DIV_LONG_2ADDR
public static final int
REM_LONG_2ADDR
public static final int
AND_LONG_2ADDR
public static final int
OR_LONG_2ADDR
public static final int
XOR_LONG_2ADDR
public static final int
SHL_LONG_2ADDR
public static final int
SHR_LONG_2ADDR
public static final int
USHR_LONG_2ADDR
public static final int
ADD_FLOAT_2ADDR
public static final int
SUB_FLOAT_2ADDR
public static final int
MUL_FLOAT_2ADDR
public static final int
DIV_FLOAT_2ADDR
public static final int
REM_FLOAT_2ADDR
public static final int
ADD_DOUBLE_2ADDR
public static final int
SUB_DOUBLE_2ADDR
public static final int
MUL_DOUBLE_2ADDR
public static final int
DIV_DOUBLE_2ADDR
public static final int
REM_DOUBLE_2ADDR
public static final int
ADD_INT_LIT16
public static final int
RSUB_INT
public static final int
MUL_INT_LIT16
public static final int
DIV_INT_LIT16
public static final int
REM_INT_LIT16
public static final int
AND_INT_LIT16
public static final int
OR_INT_LIT16
public static final int
XOR_INT_LIT16
public static final int
ADD_INT_LIT8
public static final int
RSUB_INT_LIT8
public static final int
MUL_INT_LIT8
public static final int
DIV_INT_LIT8
public static final int
REM_INT_LIT8
public static final int
AND_INT_LIT8
public static final int
OR_INT_LIT8
public static final int
XOR_INT_LIT8
public static final int
SHL_INT_LIT8
public static final int
SHR_INT_LIT8
public static final int
USHR_INT_LIT8
public static final int
PACKED_SWITCH_PAYLOAD
special pseudo-opcode value for packed-switch data payload instructions
public static final int
SPARSE_SWITCH_PAYLOAD
special pseudo-opcode value for packed-switch data payload instructions
public static final int
FILL_ARRAY_DATA_PAYLOAD
special pseudo-opcode value for fill-array-data data payload instructions
Constructors Summary
private Opcodes()
This class is uninstantiable.


             
      
        // This space intentionally left blank.
    
Methods Summary
public static intextractOpcodeFromUnit(int opcodeUnit)
Gets the opcode out of an opcode unit, the latter of which may also include one or more argument values.

param
opcodeUnit the opcode-containing code unit
return
the extracted opcode

        /*
         * Note: This method bakes in knowledge that all opcodes are
         * either single-byte or of the forms (byteValue << 8) or
         * ((byteValue << 8) | 0xff).
         */

        int lowByte = opcodeUnit & 0xff;
        return ((lowByte == 0) || (lowByte == 0xff)) ? opcodeUnit : lowByte;
    
public static booleanisValidShape(int opcode)
Determines if the given opcode has the right "shape" to be valid. This includes the range {@code 0x01..0xfe}, the range {@code 0x00ff..0xffff} where the low-order byte is either {@code 0} or {@code 0xff}, and the special opcode values {@code SPECIAL_FORMAT} and {@code NO_NEXT}. Note that not all of the opcode values that pass this test are in fact used. This method is meant to perform a quick check to reject blatantly wrong values (e.g. when validating arguments).

param
opcode the opcode value
return
{@code true} iff the value has the right "shape" to be possibly valid

        /*
         * Note: This method bakes in knowledge that all opcodes are
         * one of the forms:
         *
         *   * single byte in range 0x01..0xfe -- normal opcodes
         *   * (byteValue << 8) -- nop and data payload opcodes
         *   * ((byteValue << 8) | 0xff) -- 16-bit extended opcodes
         *   * SPECIAL_FORMAT or NO_NEXT -- pseudo-opcodes
         */

        // Note: SPECIAL_FORMAT == NO_NEXT.
        if (opcode < SPECIAL_FORMAT) {
            return false;
        } else if (opcode == SPECIAL_FORMAT) {
            return true;
        }

        int lowByte = opcode & 0xff;
        if ((lowByte == 0) || (lowByte == 0xff)) {
            return true;
        }

        return (opcode & 0xff00) == 0;