private void annotateEntries(String prefix, PrintWriter printTo, AnnotatedOutput annotateTo) {
    finishProcessingIfNecessary();

    boolean consume = (annotateTo != null);
    int amt1 = consume ? 6 : 0;
    int amt2 = consume ? 2 : 0;
    int size = table.size();
    String subPrefix = prefix + "  ";

    if (consume) {
      annotateTo.annotate(0, prefix + "tries:");
    } else {
      printTo.println(prefix + "tries:");
    }

    for (int i = 0; i < size; i++) {
      CatchTable.Entry entry = table.get(i);
      CatchHandlerList handlers = entry.getHandlers();
      String s1 =
          subPrefix + "try " + Hex.u2or4(entry.getStart()) + ".." + Hex.u2or4(entry.getEnd());
      String s2 = handlers.toHuman(subPrefix, "");

      if (consume) {
        annotateTo.annotate(amt1, s1);
        annotateTo.annotate(amt2, s2);
      } else {
        printTo.println(s1);
        printTo.println(s2);
      }
    }

    if (!consume) {
      // Only emit the handler lists if we are consuming bytes.
      return;
    }

    annotateTo.annotate(0, prefix + "handlers:");
    annotateTo.annotate(
        encodedHandlerHeaderSize, subPrefix + "size: " + Hex.u2(handlerOffsets.size()));

    int lastOffset = 0;
    CatchHandlerList lastList = null;

    for (Map.Entry<CatchHandlerList, Integer> mapping : handlerOffsets.entrySet()) {
      CatchHandlerList list = mapping.getKey();
      int offset = mapping.getValue();

      if (lastList != null) {
        annotateAndConsumeHandlers(
            lastList, lastOffset, offset - lastOffset, subPrefix, printTo, annotateTo);
      }

      lastList = list;
      lastOffset = offset;
    }

    annotateAndConsumeHandlers(
        lastList, lastOffset, encodedHandlers.length - lastOffset, subPrefix, printTo, annotateTo);
  }
Helper method to annotate or simply print the exception handlers. Only one of {@code printTo}
or {@code annotateTo} should be non-null.

@param prefix {@code non-null;} prefix for each line
@param printTo {@code null-ok;} where to print to
@param annotateTo {@code null-ok;} where to consume bytes and annotate to
android/android_framework/dex-maker/src/main/java/com/android/dx/dex/file/CatchStructs.java