public class MethodOptimizer extends RemappingMethodAdapter implements Opcodes
MethodVisitor that renames fields and methods, and removes debug
info.remapperfirstLocal, nextLocalapi, mvAALOAD, 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 |
|---|
MethodOptimizer(ClassOptimizer classOptimizer,
int access,
String desc,
MethodVisitor mv,
Remapper remapper) |
| Modifier and Type | Method and Description |
|---|---|
AnnotationVisitor |
visitAnnotation(String desc,
boolean visible)
Visits an annotation of this method.
|
AnnotationVisitor |
visitAnnotationDefault()
Visits the default value of this annotation interface method.
|
void |
visitAttribute(Attribute attr)
Visits a non standard attribute of this method.
|
void |
visitFrame(int type,
int local,
Object[] local2,
int stack,
Object[] stack2)
Visits the current state of the local variables and operand stack
elements.
|
void |
visitLdcInsn(Object cst)
Visits a LDC instruction.
|
void |
visitLineNumber(int line,
Label start)
Visits a line number declaration.
|
void |
visitLocalVariable(String name,
String desc,
String signature,
Label start,
Label end,
int index)
Visits a local variable declaration.
|
void |
visitParameter(String name,
int access)
Visits a parameter of this method.
|
AnnotationVisitor |
visitParameterAnnotation(int parameter,
String desc,
boolean visible)
Visits an annotation of a parameter this method.
|
AnnotationVisitor |
visitTypeAnnotation(int typeRef,
TypePath typePath,
String desc,
boolean visible)
Visits an annotation on a type in the method signature.
|
visitFieldInsn, visitInsnAnnotation, visitInvokeDynamicInsn, visitLocalVariableAnnotation, visitMethodInsn, visitMultiANewArrayInsn, visitTryCatchAnnotation, visitTryCatchBlock, visitTypeInsnnewLocal, newLocalMapping, setLocalType, updateNewLocals, visitIincInsn, visitMaxs, visitVarInsnvisitCode, visitEnd, visitInsn, visitIntInsn, visitJumpInsn, visitLabel, visitLookupSwitchInsn, visitTableSwitchInsnpublic MethodOptimizer(ClassOptimizer classOptimizer, int access, String desc, MethodVisitor mv, Remapper remapper)
public void visitParameter(String name, int access)
MethodVisitorvisitParameter in class MethodVisitorname - parameter name or null if none is provided.access - the parameter's access flags, only ACC_FINAL,
ACC_SYNTHETIC or/and ACC_MANDATED are
allowed (see Opcodes).public AnnotationVisitor visitAnnotationDefault()
MethodVisitorvisitAnnotationDefault in class RemappingMethodAdapterpublic AnnotationVisitor visitAnnotation(String desc, boolean visible)
MethodVisitorvisitAnnotation in class RemappingMethodAdapterdesc - the class descriptor of the annotation class.visible - true if the annotation is visible at runtime.public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible)
MethodVisitorvisitTypeAnnotation in class RemappingMethodAdaptertypeRef - a reference to the annotated type. The sort of this type
reference must be METHOD_TYPE_PARAMETER,
METHOD_TYPE_PARAMETER_BOUND,
METHOD_RETURN,
METHOD_RECEIVER,
METHOD_FORMAL_PARAMETER or THROWS. See TypeReference.typePath - the path to the annotated type argument, wildcard bound, array
element type, or static inner type within 'typeRef'. May be
null if the annotation targets 'typeRef' as a whole.desc - the class descriptor of the annotation class.visible - true if the annotation is visible at runtime.public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible)
MethodVisitorvisitParameterAnnotation in class RemappingMethodAdapterparameter - the parameter index.desc - the class descriptor of the annotation class.visible - true if the annotation is visible at runtime.public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index)
MethodVisitorvisitLocalVariable in class RemappingMethodAdaptername - the name of a local variable.desc - the type descriptor of this local variable.signature - the type signature of this local variable. May be
null if the local variable type does not use generic
types.start - the first instruction corresponding to the scope of this local
variable (inclusive).end - the last instruction corresponding to the scope of this local
variable (exclusive).index - the local variable's index.public void visitLineNumber(int line,
Label start)
MethodVisitorvisitLineNumber in class MethodVisitorline - a line number. This number refers to the source file from
which the class was compiled.start - the first instruction corresponding to this line number.public void visitFrame(int type,
int local,
Object[] local2,
int stack,
Object[] stack2)
MethodVisitorV1_6. Opcodes.F_SAME representing frame with exactly the same
locals as the previous frame and with the empty stack.Opcodes.F_SAME1 representing frame with exactly the same
locals as the previous frame and with single value on the stack (
nStack is 1 and stack[0] contains value for the
type of the stack item).Opcodes.F_APPEND representing frame with current locals are
the same as the locals in the previous frame, except that additional
locals are defined (nLocal is 1, 2 or 3 and
local elements contains values representing added types).Opcodes.F_CHOP representing frame with current locals are the
same as the locals in the previous frame, except that the last 1-3 locals
are absent and with the empty stack (nLocals is 1, 2 or 3).Opcodes.F_FULL representing complete frame data.visitFrame in class RemappingMethodAdaptertype - the type of this stack map frame. Must be
Opcodes.F_NEW for expanded frames, or
Opcodes.F_FULL, Opcodes.F_APPEND,
Opcodes.F_CHOP, Opcodes.F_SAME or
Opcodes.F_APPEND, Opcodes.F_SAME1 for
compressed frames.local - the number of local variables in the visited frame.local2 - the local variable types in this frame. This array must not be
modified. Primitive types are represented by
Opcodes.TOP, Opcodes.INTEGER,
Opcodes.FLOAT, Opcodes.LONG,
Opcodes.DOUBLE,Opcodes.NULL or
Opcodes.UNINITIALIZED_THIS (long and double are
represented by a single element). Reference types are
represented by String objects (representing internal names),
and uninitialized types by Label objects (this label
designates the NEW instruction that created this uninitialized
value).stack - the number of operand stack elements in the visited frame.stack2 - the operand stack types in this frame. This array must not be
modified. Its content has the same format as the "local"
array.public void visitAttribute(Attribute attr)
MethodVisitorvisitAttribute in class MethodVisitorattr - an attribute.public void visitLdcInsn(Object cst)
MethodVisitor
if (cst instanceof Integer) {
// ...
} else if (cst instanceof Float) {
// ...
} else if (cst instanceof Long) {
// ...
} else if (cst instanceof Double) {
// ...
} else if (cst instanceof String) {
// ...
} else if (cst instanceof Type) {
int sort = ((Type) cst).getSort();
if (sort == Type.OBJECT) {
// ...
} else if (sort == Type.ARRAY) {
// ...
} else if (sort == Type.METHOD) {
// ...
} else {
// throw an exception
}
} else if (cst instanceof Handle) {
// ...
} else {
// throw an exception
}
visitLdcInsn in class RemappingMethodAdaptercst - the constant to be loaded on the stack. This parameter must be
a non null Integer, a Float, a Long, a
Double, a String, a Type of OBJECT or
ARRAY sort for .class constants, for classes whose
version is 49.0, a Type of METHOD sort or a
Handle for MethodType and MethodHandle constants, for
classes whose version is 51.0.Copyright © 2009-2014 Oracle Corporation. All Rights Reserved.