public void replaceSuccessor(int oldIndex, int newIndex) {
    if (oldIndex == newIndex) {
      return;
    }

    // Update us.
    successors.set(newIndex);

    if (primarySuccessor == oldIndex) {
      primarySuccessor = newIndex;
    }

    for (int i = successorList.size() - 1; i >= 0; i--) {
      if (successorList.get(i) == oldIndex) {
        successorList.set(i, newIndex);
      }
    }

    successors.clear(oldIndex);

    // Update new successor.
    parent.getBlocks().get(newIndex).predecessors.set(index);

    // Update old successor.
    parent.getBlocks().get(oldIndex).predecessors.clear(index);
  }
Replaces an old successor with a new successor. This will throw RuntimeException if {@code
oldIndex} was not a successor.

@param oldIndex index of old successor block
@param newIndex index of new successor block
android/android_framework/dex-maker/src/main/java/com/android/dx/ssa/SsaBasicBlock.java