ataspectj.instrumentation
Class InstrumentationFactory

java.lang.Object
  extended by ataspectj.AtAspectjComponent
      extended by ataspectj.instrumentation.InstrumentationFactory

public class InstrumentationFactory
extends AtAspectjComponent


Field Summary
 
Fields inherited from class ataspectj.AtAspectjComponent
barrier, CODEPRINT, DEBUG, VERBOSE
 
Constructor Summary
InstrumentationFactory()
           
 
Method Summary
static org.apache.bcel.classfile.Method addCurrentJump(org.apache.bcel.generic.MethodGen mg, int startPc, int endPc, org.apache.bcel.generic.ConstantPoolGen cg)
          It adds a jump instruction before the startPC that target the endPC.
static org.apache.bcel.classfile.Method addNewInvokeInstructionList(org.apache.bcel.generic.MethodGen mg, int endPc, org.apache.bcel.generic.InstructionList invokeList)
          It adds the invoke instructions after the endPc (the target of the added jump).
protected static byte[] addNOPByte(byte[] oldBytecode)
          It adds a NOP byte at the end of the array.
static org.apache.bcel.generic.MethodGen createMethodGen(int flags, java.lang.String methodName, java.lang.String className, IndexRepository[] params, org.apache.bcel.generic.InstructionList il, org.apache.bcel.generic.ConstantPoolGen cg)
          It creates the MethodGen for the new extracted Method.
static void stampaInstructionHandles(org.apache.bcel.generic.InstructionList il)
          It prints the InstrcionsHandles of the given instruction list.
static void stampaInstructions(byte[] bc)
          It prints the Instrcions of the given bytecode
static void updateAnnotationBoundaries(org.apache.bcel.classfile.Attribute[] all, int startPc, int endPc, int offset)
          It updates the boundaries (startPC and endPC) icrementing them by the offset.
 
Methods inherited from class ataspectj.AtAspectjComponent
done
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InstrumentationFactory

public InstrumentationFactory()
Method Detail

addNOPByte

protected static byte[] addNOPByte(byte[] oldBytecode)
It adds a NOP byte at the end of the array.

Parameters:
oldBytecode - the original bytecode
Returns:
the modified array.

addCurrentJump

public static org.apache.bcel.classfile.Method addCurrentJump(org.apache.bcel.generic.MethodGen mg,
                                                              int startPc,
                                                              int endPc,
                                                              org.apache.bcel.generic.ConstantPoolGen cg)
It adds a jump instruction before the startPC that target the endPC. after the execution startPc and endPc have to be incremented by 3 (the lenght of the jump instruction).

Parameters:
mg - the MethodGen.
startPc - the startPC, also the index where insert the jump.
endPc - the endPC, also the taget.
cg - the ConstantPoolGen
Returns:
The modified method.

updateAnnotationBoundaries

public static void updateAnnotationBoundaries(org.apache.bcel.classfile.Attribute[] all,
                                              int startPc,
                                              int endPc,
                                              int offset)
It updates the boundaries (startPC and endPC) icrementing them by the offset. The method look to all the CodeAttributes contained into the interval and following the interval.

Parameters:
all - All tThe Attribute.
startPc - The startPC
endPc - The endPc.
offset - The offset to use.

createMethodGen

public static org.apache.bcel.generic.MethodGen createMethodGen(int flags,
                                                                java.lang.String methodName,
                                                                java.lang.String className,
                                                                IndexRepository[] params,
                                                                org.apache.bcel.generic.InstructionList il,
                                                                org.apache.bcel.generic.ConstantPoolGen cg)
It creates the MethodGen for the new extracted Method.

Parameters:
flags - The flags inherited by the original method.
methodName - The new method name.
className - The Class of method.
params - The parameters of the new method.
il - The instruction list of the new method.
cg - The costant pool gen
Returns:
The MethodGen created.

addNewInvokeInstructionList

public static org.apache.bcel.classfile.Method addNewInvokeInstructionList(org.apache.bcel.generic.MethodGen mg,
                                                                           int endPc,
                                                                           org.apache.bcel.generic.InstructionList invokeList)
It adds the invoke instructions after the endPc (the target of the added jump).

Parameters:
mg - The MethodGen to modify.
endPc - The endPc where add the invoke instrucions.
invokeList - The invoke instructions.
Returns:
The Method modified.

stampaInstructions

public static void stampaInstructions(byte[] bc)
It prints the Instrcions of the given bytecode

Parameters:
bc - the bytecode to print.

stampaInstructionHandles

public static void stampaInstructionHandles(org.apache.bcel.generic.InstructionList il)
It prints the InstrcionsHandles of the given instruction list.

Parameters:
il - The instruction list to print.