org.compass.core.util.asm.optimizer
Class MethodOptimizer

java.lang.Object
  extended by org.compass.core.util.asm.MethodAdapter
      extended by org.compass.core.util.asm.commons.LocalVariablesSorter
          extended by org.compass.core.util.asm.commons.RemappingMethodAdapter
              extended by org.compass.core.util.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

Field Summary
 
Fields inherited from class org.compass.core.util.asm.commons.RemappingMethodAdapter
remapper
 
Fields inherited from class org.compass.core.util.asm.commons.LocalVariablesSorter
firstLocal, nextLocal
 
Fields inherited from class org.compass.core.util.asm.MethodAdapter
mv
 
Constructor Summary
MethodOptimizer(int access, String desc, MethodVisitor mv, Remapper remapper)
           
 
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, Object[] local2, int stack, 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(String name, String desc, String signature, Label start, Label end, int index)
          Visits a local variable declaration.
 AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible)
          Visits an annotation of a parameter this method.
 
Methods inherited from class org.compass.core.util.asm.commons.RemappingMethodAdapter
visitAnnotation, visitFieldInsn, visitLdcInsn, visitMethodInsn, visitMultiANewArrayInsn, visitTryCatchBlock, visitTypeInsn
 
Methods inherited from class org.compass.core.util.asm.commons.LocalVariablesSorter
newLocal, newLocalMapping, setLocalType, visitIincInsn, visitMaxs, visitVarInsn
 
Methods inherited from class org.compass.core.util.asm.MethodAdapter
visitCode, visitEnd, visitInsn, visitIntInsn, visitJumpInsn, visitLabel, visitLookupSwitchInsn, visitTableSwitchInsn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MethodOptimizer

public MethodOptimizer(int access,
                       String desc,
                       MethodVisitor mv,
                       Remapper remapper)
Method Detail

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,
                                                  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(String name,
                               String desc,
                               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,
                       Object[] local2,
                       int stack,
                       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):

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.


Copyright (c) 2004-2008 The Compass Project.