AALOAD, AASTORE, ACC_ABSTRACT, ACC_ANNOTATION, ACC_BRIDGE, ACC_DEPRECATED, ACC_ENUM, ACC_FINAL, ACC_INTERFACE, ACC_MANDATED, ACC_NATIVE, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_STRICT, ACC_SUPER, ACC_SYNCHRONIZED, ACC_SYNTHETIC, ACC_TRANSIENT, ACC_VARARGS, ACC_VOLATILE, ACONST_NULL, ALOAD, ANEWARRAY, ARETURN, ARRAYLENGTH, ASM4, ASM5, ASTORE, ATHROW, BALOAD, BASTORE, BIPUSH, CALOAD, CASTORE, CHECKCAST, D2F, D2I, D2L, DADD, DALOAD, DASTORE, DCMPG, DCMPL, DCONST_0, DCONST_1, DDIV, DLOAD, DMUL, DNEG, DOUBLE, DREM, DRETURN, DSTORE, DSUB, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, F_APPEND, F_CHOP, F_FULL, F_NEW, F_SAME, F_SAME1, F2D, F2I, F2L, FADD, FALOAD, FASTORE, FCMPG, FCMPL, FCONST_0, FCONST_1, FCONST_2, FDIV, FLOAD, FLOAT, FMUL, FNEG, FREM, FRETURN, FSTORE, FSUB, GETFIELD, GETSTATIC, GOTO, H_GETFIELD, H_GETSTATIC, H_INVOKEINTERFACE, H_INVOKESPECIAL, H_INVOKESTATIC, H_INVOKEVIRTUAL, H_NEWINVOKESPECIAL, H_PUTFIELD, H_PUTSTATIC, I2B, I2C, I2D, I2F, I2L, I2S, IADD, IALOAD, IAND, IASTORE, ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5, ICONST_M1, IDIV, IF_ACMPEQ, IF_ACMPNE, IF_ICMPEQ, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ICMPLT, IF_ICMPNE, IFEQ, IFGE, IFGT, IFLE, IFLT, IFNE, IFNONNULL, IFNULL, IINC, ILOAD, IMUL, INEG, INSTANCEOF, INTEGER, INVOKEDYNAMIC, INVOKEINTERFACE, INVOKESPECIAL, INVOKESTATIC, INVOKEVIRTUAL, IOR, IREM, IRETURN, ISHL, ISHR, ISTORE, ISUB, IUSHR, IXOR, JSR, L2D, L2F, L2I, LADD, LALOAD, LAND, LASTORE, LCMP, LCONST_0, LCONST_1, LDC, LDIV, LLOAD, LMUL, LNEG, LONG, LOOKUPSWITCH, LOR, LREM, LRETURN, LSHL, LSHR, LSTORE, LSUB, LUSHR, LXOR, MONITORENTER, MONITOREXIT, MULTIANEWARRAY, NEW, NEWARRAY, NOP, NULL, POP, POP2, PUTFIELD, PUTSTATIC, RET, RETURN, SALOAD, SASTORE, SIPUSH, SWAP, T_BOOLEAN, T_BYTE, T_CHAR, T_DOUBLE, T_FLOAT, T_INT, T_LONG, T_SHORT, TABLESWITCH, TOP, UNINITIALIZED_THIS, V1_1, V1_2, V1_3, V1_4, V1_5, V1_6, V1_7, V1_8
Constructor and Description |
---|
CodeFlow() |
Modifier and Type | Method and Description |
---|---|
static boolean |
areBoxingCompatible(String desc1,
String desc2)
Determine if boxing/unboxing can get from one type to the other.
|
static String |
createSignatureDescriptor(Constructor<?> ctor)
Create the JVM signature descriptor for a constructor.
|
static String |
createSignatureDescriptor(Method method)
Create the JVM signature descriptor for a method.
|
void |
enterCompilationScope()
Enter a new compilation scope, usually due to nested expression evaluation.
|
void |
exitCompilationScope()
Exit a compilation scope, usually after a nested expression has been evaluated.
|
static void |
insertBoxIfNecessary(MethodVisitor mv,
char ch)
Determine the appropriate boxing instruction for a specific type (if it needs
boxing) and insert the instruction into the supplied visitor.
|
static void |
insertBoxIfNecessary(MethodVisitor mv,
String descriptor)
Determine the appropriate boxing instruction for a specific type (if it needs
boxing) and insert the instruction into the supplied visitor.
|
static void |
insertCheckCast(MethodVisitor mv,
String descriptor)
Insert the appropriate CHECKCAST instruction for the supplied descriptor.
|
static void |
insertUnboxInsns(MethodVisitor mv,
char ch,
String stackDescriptor)
Insert any necessary cast and value call to convert from a boxed type to a
primitive value
|
static boolean |
isBooleanCompatible(String descriptor) |
static boolean |
isPrimitive(String descriptor) |
static boolean |
isPrimitiveArray(String descriptor) |
static boolean |
isPrimitiveOrUnboxableSupportedNumber(String descriptor)
Determine if the supplied descriptor is for a supported number.
|
static boolean |
isPrimitiveOrUnboxableSupportedNumberOrBoolean(String descriptor)
Determine if the supplied descriptor is for a supported number type or boolean.
|
String |
lastDescriptor() |
void |
loadTarget(MethodVisitor mv)
Push the byte code to load the target (i.e.
|
void |
pushDescriptor(String descriptor)
Record the descriptor for the most recently evaluated expression element.
|
static String |
toDescriptor(Class<?> type)
Deduce the descriptor for a type.
|
static String |
toDescriptorFromObject(Object value)
Determine the descriptor for an object instance (or
null ). |
static String |
toJVMDescriptor(Class<?> clazz)
Determine the JVM descriptor for a specified class.
|
static String[] |
toParamDescriptors(Constructor<?> ctor)
Create an array of descriptors representing the parameter types for the supplied
constructor.
|
static String[] |
toParamDescriptors(Method method)
Create an array of descriptors representing the parameter types for the supplied
method.
|
static char |
toPrimitiveTargetDesc(String descriptor) |
void |
unboxBooleanIfNecessary(MethodVisitor mv)
If the codeflow shows the last expression evaluated to java.lang.Boolean then
insert the necessary instructions to unbox that to a boolean primitive.
|
public void loadTarget(MethodVisitor mv)
mv
- the visitor into which the load instruction should be insertedpublic void pushDescriptor(String descriptor)
descriptor
- type descriptor for most recently evaluated elementpublic void enterCompilationScope()
public void exitCompilationScope()
public String lastDescriptor()
public void unboxBooleanIfNecessary(MethodVisitor mv)
mv
- the visitor into which new instructions should be insertedpublic static void insertUnboxInsns(MethodVisitor mv, char ch, String stackDescriptor)
mv
- the method visitor into which instructions should be insertedch
- the primitive type desired as outputstackDescriptor
- the descriptor of the type on top of the stackpublic static String createSignatureDescriptor(Method method)
method
- the methodpublic static String createSignatureDescriptor(Constructor<?> ctor)
ctor
- the constructorpublic static String toJVMDescriptor(Class<?> clazz)
clazz
- a classpublic static String toDescriptorFromObject(Object value)
null
).value
- an object (possibly null
)null
value)public static boolean isBooleanCompatible(String descriptor)
descriptor
- type descriptortrue
if the descriptor is for a boolean primitive or boolean reference typepublic static boolean isPrimitive(String descriptor)
descriptor
- type descriptortrue
if the descriptor is for a primitive typepublic static boolean isPrimitiveArray(String descriptor)
descriptor
- the descriptor for a possible primitive arraytrue
if the descriptor is for a primitive array (e.g. "[[I")public static boolean areBoxingCompatible(String desc1, String desc2)
true
if it is possible to get (via boxing) from one descriptor to the otherpublic static boolean isPrimitiveOrUnboxableSupportedNumberOrBoolean(String descriptor)
descriptor
- the descriptor for a typetrue
if the descriptor is for a supported numeric type or booleanpublic static boolean isPrimitiveOrUnboxableSupportedNumber(String descriptor)
descriptor
- the descriptor for a typetrue
if the descriptor is for a supported numeric typepublic static char toPrimitiveTargetDesc(String descriptor)
descriptor
- a descriptor for a type that should have a primitive representationpublic static void insertCheckCast(MethodVisitor mv, String descriptor)
mv
- the target visitor into which the instruction should be inserteddescriptor
- the descriptor of the type to cast topublic static void insertBoxIfNecessary(MethodVisitor mv, String descriptor)
mv
- the target visitor for the new instructionsdescriptor
- the descriptor of a type that may or may not need boxingpublic static void insertBoxIfNecessary(MethodVisitor mv, char ch)
mv
- the target visitor for the new instructionsch
- the descriptor of the type that might need boxingpublic static String toDescriptor(Class<?> type)
type
- the type (may be primitive) for which to determine the descriptorpublic static String[] toParamDescriptors(Method method)
method
- a Methodpublic static String[] toParamDescriptors(Constructor<?> ctor)
ctor
- a Constructor