FileDocCategorySizeDatePackage
ByteOps.javaAPI DocAndroid 5.1 API22353Thu Mar 12 22:18:30 GMT 2015com.android.dx.cf.code

ByteOps

public class ByteOps extends Object
Constants and utility methods for dealing with bytecode arrays at an opcode level.

Fields Summary
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
NEWARRAY_BOOLEAN
public static final int
NEWARRAY_CHAR
public static final int
NEWARRAY_FLOAT
public static final int
NEWARRAY_DOUBLE
public static final int
NEWARRAY_BYTE
public static final int
NEWARRAY_SHORT
public static final int
NEWARRAY_INT
public static final int
NEWARRAY_LONG
public static final int
FMT_INVALID
invalid
public static final int
FMT_NO_ARGS
"-": {@code op}
public static final int
FMT_NO_ARGS_LOCALS_1
"0": {@code op}; implies {@code max_locals >= 1}
public static final int
FMT_NO_ARGS_LOCALS_2
"1": {@code op}; implies {@code max_locals >= 2}
public static final int
FMT_NO_ARGS_LOCALS_3
"2": {@code op}; implies {@code max_locals >= 3}
public static final int
FMT_NO_ARGS_LOCALS_4
"3": {@code op}; implies {@code max_locals >= 4}
public static final int
FMT_NO_ARGS_LOCALS_5
"4": {@code op}; implies {@code max_locals >= 5}
public static final int
FMT_BRANCH
"b": {@code op target target}
public static final int
FMT_WIDE_BRANCH
"c": {@code op target target target target}
public static final int
FMT_CPI
"p": {@code op #cpi #cpi}; constant restricted as specified
public static final int
FMT_LOCAL_1
"l": {@code op local}; category-1 local; implies {@code max_locals} is at least two more than the given local number
public static final int
FMT_LOCAL_2
"m": {@code op local}; category-2 local; implies {@code max_locals} is at least two more than the given local number
public static final int
FMT_LITERAL_BYTE
"y": {@code op #byte} ({@code bipush} and {@code newarray})
public static final int
FMT_INVOKEINTERFACE
"I": {@code invokeinterface cpi cpi count 0}
public static final int
FMT_LDC
"L": {@code ldc #cpi}; constant restricted as specified
public static final int
FMT_SIPUSH
"S": {@code sipush #byte #byte}
public static final int
FMT_TABLESWITCH
"T": {@code tableswitch ...}
public static final int
FMT_LOOKUPSWITCH
"U": {@code lookupswitch ...}
public static final int
FMT_MULTIANEWARRAY
"M": {@code multianewarray cpi cpi dims}
public static final int
FMT_WIDE
"W": {@code wide ...}
public static final int
FMT_MASK
mask for the bits representing the opcode format
public static final int
CPOK_Integer
"I": flag bit for valid cp type for {@code Integer}
public static final int
CPOK_Float
"F": flag bit for valid cp type for {@code Float}
public static final int
CPOK_Long
"J": flag bit for valid cp type for {@code Long}
public static final int
CPOK_Double
"D": flag bit for valid cp type for {@code Double}
public static final int
CPOK_Class
"c": flag bit for valid cp type for {@code Class}
public static final int
CPOK_String
"s": flag bit for valid cp type for {@code String}
public static final int
CPOK_Fieldref
"f": flag bit for valid cp type for {@code Fieldref}
public static final int
CPOK_Methodref
"m": flag bit for valid cp type for {@code Methodref}
public static final int
CPOK_InterfaceMethodref
"i": flag bit for valid cp type for {@code InterfaceMethodref}
private static final int[]
OPCODE_INFO
{@code non-null;} map from opcodes to format or'ed with allowed constant pool types
private static final String[]
OPCODE_NAMES
{@code non-null;} map from opcodes to their names
private static final String
OPCODE_DETAILS
{@code non-null;} bigass string describing all the opcodes
Constructors Summary
private ByteOps()
This class is uninstantiable.


     
        // Set up OPCODE_INFO and OPCODE_NAMES.
        String s = OPCODE_DETAILS;
        int len = s.length();

        for (int i = 0; i < len; /*i*/) {
            int idx = (Character.digit(s.charAt(i), 16) << 4) |
                Character.digit(s.charAt(i + 1), 16);
            int info;
            switch (s.charAt(i + 3)) {
                case '-": info = FMT_NO_ARGS; break;
                case '0": info = FMT_NO_ARGS_LOCALS_1; break;
                case '1": info = FMT_NO_ARGS_LOCALS_2; break;
                case '2": info = FMT_NO_ARGS_LOCALS_3; break;
                case '3": info = FMT_NO_ARGS_LOCALS_4; break;
                case '4": info = FMT_NO_ARGS_LOCALS_5; break;
                case 'b": info = FMT_BRANCH; break;
                case 'c": info = FMT_WIDE_BRANCH; break;
                case 'p": info = FMT_CPI; break;
                case 'l": info = FMT_LOCAL_1; break;
                case 'm": info = FMT_LOCAL_2; break;
                case 'y": info = FMT_LITERAL_BYTE; break;
                case 'I": info = FMT_INVOKEINTERFACE; break;
                case 'L": info = FMT_LDC; break;
                case 'S": info = FMT_SIPUSH; break;
                case 'T": info = FMT_TABLESWITCH; break;
                case 'U": info = FMT_LOOKUPSWITCH; break;
                case 'M": info = FMT_MULTIANEWARRAY; break;
                case 'W": info = FMT_WIDE; break;
                default: info = FMT_INVALID; break;
            }

            i += 5;
            if (s.charAt(i - 1) == ':") {
                inner:
                for (;;) {
                    switch (s.charAt(i)) {
                        case 'I": info |= CPOK_Integer; break;
                        case 'F": info |= CPOK_Float; break;
                        case 'J": info |= CPOK_Long; break;
                        case 'D": info |= CPOK_Double; break;
                        case 'c": info |= CPOK_Class; break;
                        case 's": info |= CPOK_String; break;
                        case 'f": info |= CPOK_Fieldref; break;
                        case 'm": info |= CPOK_Methodref; break;
                        case 'i": info |= CPOK_InterfaceMethodref; break;
                        default: break inner;
                    }
                    i++;
                }
                i++;
            }

            int endAt = s.indexOf(';", i);
            OPCODE_INFO[idx] = info;
            OPCODE_NAMES[idx] = s.substring(i, endAt);
            i = endAt + 1;
        }
    
        // This space intentionally left blank.
    
Methods Summary
public static intopInfo(int opcode)
Gets the format and allowed cp types of the given opcode.

param
opcode {@code >= 0, <= 255;} the opcode
return
its format and allowed cp types

        return OPCODE_INFO[opcode];
    
public static java.lang.StringopName(int opcode)
Gets the name of the given opcode.

param
opcode {@code >= 0, <= 255;} the opcode
return
{@code non-null;} its name

        String result = OPCODE_NAMES[opcode];

        if (result == null) {
            result = "unused_" + Hex.u1(opcode);
            OPCODE_NAMES[opcode] = result;
        }

        return result;