org.objectweb.asm.optimizer
Class MethodOptimizer
java.lang.Object
org.objectweb.asm.MethodAdapter
org.objectweb.asm.commons.LocalVariablesSorter
org.objectweb.asm.commons.RemappingMethodAdapter
org.objectweb.asm.optimizer.MethodOptimizer
- All Implemented Interfaces:
- MethodVisitor
public class MethodOptimizer
- extends RemappingMethodAdapter
A MethodAdapter
that renames fields and methods, and removes debug
info.
- Author:
- Eugene Kuleshov
Method Summary |
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,
java.lang.Object[] local2,
int stack,
java.lang.Object[] stack2)
Visits the current state of the local variables and operand stack
elements. |
void |
visitLineNumber(int line,
Label start)
Visits a line number declaration. |
void |
visitLocalVariable(java.lang.String name,
java.lang.String desc,
java.lang.String signature,
Label start,
Label end,
int index)
Visits a local variable declaration. |
AnnotationVisitor |
visitParameterAnnotation(int parameter,
java.lang.String desc,
boolean visible)
Visits an annotation of a parameter this method. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MethodOptimizer
public MethodOptimizer(int access,
java.lang.String desc,
MethodVisitor mv,
Remapper remapper)
visitAnnotationDefault
public AnnotationVisitor visitAnnotationDefault()
- Description copied from interface:
MethodVisitor
- Visits the default value of this annotation interface method.
- Specified by:
visitAnnotationDefault
in interface MethodVisitor
- Overrides:
visitAnnotationDefault
in class RemappingMethodAdapter
- Returns:
- a visitor to the visit the actual default value of this
annotation interface method, or null if this visitor
is not interested in visiting this default value. The 'name'
parameters passed to the methods of this annotation visitor are
ignored. Moreover, exacly one visit method must be called on this
annotation visitor, followed by visitEnd.
visitParameterAnnotation
public AnnotationVisitor visitParameterAnnotation(int parameter,
java.lang.String desc,
boolean visible)
- Description copied from interface:
MethodVisitor
- Visits an annotation of a parameter this method.
- Specified by:
visitParameterAnnotation
in interface MethodVisitor
- Overrides:
visitParameterAnnotation
in class RemappingMethodAdapter
- Parameters:
parameter
- the parameter index.desc
- the class descriptor of the annotation class.visible
- true if the annotation is visible at runtime.
- Returns:
- a visitor to visit the annotation values, or null if
this visitor is not interested in visiting this annotation.
visitLocalVariable
public void visitLocalVariable(java.lang.String name,
java.lang.String desc,
java.lang.String signature,
Label start,
Label end,
int index)
- Description copied from interface:
MethodVisitor
- Visits a local variable declaration.
- Specified by:
visitLocalVariable
in interface MethodVisitor
- Overrides:
visitLocalVariable
in class RemappingMethodAdapter
- Parameters:
name
- 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.
visitLineNumber
public void visitLineNumber(int line,
Label start)
- Description copied from interface:
MethodVisitor
- Visits a line number declaration.
- Specified by:
visitLineNumber
in interface MethodVisitor
- Overrides:
visitLineNumber
in class MethodAdapter
- Parameters:
line
- 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.
visitFrame
public void visitFrame(int type,
int local,
java.lang.Object[] local2,
int stack,
java.lang.Object[] stack2)
- Description copied from interface:
MethodVisitor
- Visits the current state of the local variables and operand stack
elements. This method must(*) be called just before any
instruction i that follows an unconditionnal branch instruction
such as GOTO or THROW, that is the target of a jump instruction, or that
starts an exception handler block. The visited types must describe the
values of the local variables and of the operand stack elements just
before i is executed.
(*) this is mandatory only
for classes whose version is greater than or equal to
V1_6
.
Packed frames are basically
"deltas" from the state of the previous frame (very first frame is
implicitly defined by the method's parameters and access flags):
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.
- Specified by:
visitFrame
in interface MethodVisitor
- Overrides:
visitFrame
in class RemappingMethodAdapter
- Parameters:
type
- 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.
visitAttribute
public void visitAttribute(Attribute attr)
- Description copied from interface:
MethodVisitor
- Visits a non standard attribute of this method.
- Specified by:
visitAttribute
in interface MethodVisitor
- Overrides:
visitAttribute
in class MethodAdapter
- Parameters:
attr
- an attribute.