private void transformBasicBlock(BasicBlock block) { List<Instruction> instructions = block.getInstructions(); for (int i = 0; i < instructions.size(); ++i) { Instruction insn = instructions.get(i); if (insn instanceof InvokeInstruction) { InvokeInstruction invoke = (InvokeInstruction) insn; List<Instruction> replacement = transformInvoke(invoke); if (replacement != null) { instructions.set(i, new EmptyInstruction()); instructions.addAll(i, replacement); i += replacement.size(); } } } }