Example usage for org.aspectj.apache.bcel.generic InstructionHandle getTargeters

List of usage examples for org.aspectj.apache.bcel.generic InstructionHandle getTargeters

Introduction

In this page you can find the example usage for org.aspectj.apache.bcel.generic InstructionHandle getTargeters.

Prototype

public Set<InstructionTargeter> getTargeters() 

Source Link

Usage

From source file:br.jabuti.instrumenter.bytecode.bcel.Instrumenter.java

License:Open Source License

/** Redo all the tables for the method after an instruction has been
 inserted. The programer does not need to call it explicitly because
 {@link Instrumenter#insertBefore(InstructionHandle ih, Instruction x)}
 and/* w ww.j a  va2s  .c  o  m*/
 {@link Instrumenter#insertBefore(InstructionHandle ih, InstructionList x)}
 call this method.
        
 @param ih The original instruction, before which the new instruction
 has been inserted
 @param newih The new instruction, that took the place of the old one
 */

private void recalTables(InstructionHandle ih, InstructionHandle newih) {
    InstructionTargeter[] it = ih.getTargeters();

    for (int i = 0; it != null && i < it.length; i++) {
        it[i].updateTarget(ih, newih);
    }
    // O codigo acima deve fazer o mesmo que o codigo abaixo.
    /*
     CodeExceptionGen[] ceg = meth.getExceptionHandlers();
     for (int i = 0; i < ceg.length; i++)
     {
     if (ceg[i].getStartPC() == ih)
     ceg[i].setStartPC(newih);
     }
     LocalVariableGen[] lvg = meth.getLocalVariables();
     for (int i = 0; i < lvg.length; i++)
     {
     if (lvg[i].getStart() == ih)
     lvg[i].setStart(newih);
     }
     LineNumberGen[] lng = meth.getLineNumbers();
     for (int i = 0; i < lng.length; i++)
     {
     if (lng[i].getInstruction() == ih)
     lng[i].setInstruction(newih);
     }
     il.redirectBranches(ih, newih);
     */
}