public void reverseBranch(int which, CodeAddress newTarget) {
    int size = insns.size();
    int index = size - which - 1;
    TargetInsn targetInsn;

    try {
      targetInsn = (TargetInsn) insns.get(index);
    } catch (IndexOutOfBoundsException ex) {
      // Translate the exception.
      throw new IllegalArgumentException("too few instructions");
    } catch (ClassCastException ex) {
      // Translate the exception.
      throw new IllegalArgumentException("non-reversible instruction");
    }

    /*
     * No need to call this.set(), since the format and other info
     * are the same.
     */
    insns.set(index, targetInsn.withNewTargetAndReversed(newTarget));
  }
Reverses a branch which is buried a given number of instructions backward in the output. It is
illegal to call this unless the indicated instruction really is a reversible branch.

@param which how many instructions back to find the branch; {@code 0} is the most recently
    added instruction, {@code 1} is the instruction before that, etc.
@param newTarget {@code non-null;} the new target for the reversed branch
android/android_framework/dex-maker/src/main/java/com/android/dx/dex/code/OutputFinisher.java