Search in sources :

Example 1 with EmptyVisitor

use of org.apache.bcel.generic.EmptyVisitor in project jop by jop-devel.

the class ConstantPoolRebuilder method updateMethodGen.

public void updateMethodGen(MethodInfo methodInfo, MethodGen methodGen) {
    methodGen.setConstantPool(newPool);
    if (methodInfo.hasCode()) {
        // update all instructions
        InstructionList il = methodInfo.getCode().getInstructionList();
        class InstructionVisitor extends EmptyVisitor {

            @Override
            public void visitCPInstruction(CPInstruction obj) {
                obj.setIndex(mapIndex(obj.getIndex()));
            }
        }
        InstructionVisitor iv = new InstructionVisitor();
        for (InstructionHandle ih : il.getInstructionHandles()) {
            ih.getInstruction().accept(iv);
        }
        updateAttributes(methodInfo, methodGen.getCodeAttributes());
    }
    updateAttributes(methodInfo, methodGen.getAttributes());
}
Also used : CPInstruction(org.apache.bcel.generic.CPInstruction) InstructionList(org.apache.bcel.generic.InstructionList) InstructionHandle(org.apache.bcel.generic.InstructionHandle) EmptyVisitor(org.apache.bcel.generic.EmptyVisitor)

Aggregations

CPInstruction (org.apache.bcel.generic.CPInstruction)1 EmptyVisitor (org.apache.bcel.generic.EmptyVisitor)1 InstructionHandle (org.apache.bcel.generic.InstructionHandle)1 InstructionList (org.apache.bcel.generic.InstructionList)1