public Section appendSection(int maxByteCount, String name) {
    if ((maxByteCount & 3) != 0) {
      throw new IllegalStateException("Not four byte aligned!");
    }
    int limit = nextSectionStart + maxByteCount;
    ByteBuffer sectionData = data.duplicate();
    sectionData.order(ByteOrder.LITTLE_ENDIAN); // necessary?
    sectionData.position(nextSectionStart);
    sectionData.limit(limit);
    Section result = new Section(name, sectionData);
    nextSectionStart = limit;
    return result;
  }
It is the caller's responsibility to close {@code in}.
android/android_framework/dex-maker/src/main/java/com/android/dex/Dex.java