Program: 101481
Project: 101481
Buggy source:
/** 
 * Write out the object to the given ObjectOutputStream. There are 3 ways of doing this - according to the 3 implementations of Passage. <ul> <li>Distinct: If we write out a list if verse ordinals then the space used is 4 bytes per verse. <li>Bitwise: If we write out a bitmap then the space used is something like 31104/8 = 4k bytes. <li>Ranged: The we write a list of start/end pairs then the space used is 8 bytes per range. </ul> Since we can take our time about this section, we calculate the optimal storage method before we do the saving. If some methods come out equal first then bitwise is preferred, then distinct, then ranged, because I imagine that for speed of deserialization this is the sensible order. I've not tested it though.
 * @param out The stream to write our state to
 * @throws IOException if the read fails
 */
protected void writeObjectSupport(ObjectOutputStream out) throws IOException {
  int bitwise_size=getVersification().maximumOrdinal();
  int ranged_size=8 * countRanges(RestrictionType.NONE);
  int distinct_size=4 * countVerses();
  if (bitwise_size <= ranged_size && bitwise_size <= distinct_size) {
    out.writeInt(BITWISE);
    BitSet store=new BitSet(bitwise_size);
    for (    Key aKey : this) {
      Verse verse=(Verse)aKey;
      store.set(verse.getOrdinal() - 1);
    }
    out.writeObject(store);
  }
 else   if (distinct_size <= ranged_size) {
    out.writeInt(DISTINCT);
    out.writeInt(countVerses());
    for (    Key aKey : this) {
      Verse verse=(Verse)aKey;
      out.writeInt(verse.getOrdinal());
    }
  }
 else {
    out.writeInt(RANGED);
    out.writeInt(countRanges(RestrictionType.NONE));
    Iterator<Key> it=rangeIterator(RestrictionType.NONE);
    while (it.hasNext()) {
      VerseRange range=(VerseRange)it.next();
      out.writeInt(range.getStart().getOrdinal());
      out.writeInt(range.getCardinality());
    }
  }
}

Fixed version (ground truth):
/** 
 * Write out the object to the given ObjectOutputStream. There are 3 ways of doing this - according to the 3 implementations of Passage. <ul> <li>Distinct: If we write out a list if verse ordinals then the space used is 4 bytes per verse. <li>Bitwise: If we write out a bitmap then the space used is something like 31104/8 = 4k bytes. <li>Ranged: The we write a list of start/end pairs then the space used is 8 bytes per range. </ul> Since we can take our time about this section, we calculate the optimal storage method before we do the saving. If some methods come out equal first then bitwise is preferred, then distinct, then ranged, because I imagine that for speed of deserialization this is the sensible order. I've not tested it though.
 * @param out The stream to write our state to
 * @throws IOException if the read fails
 */
protected void writeObjectSupport(ObjectOutputStream out) throws IOException {
  out.writeUTF(v11n.getName());
  int bitwise_size=v11n.maximumOrdinal();
  int ranged_size=8 * countRanges(RestrictionType.NONE);
  int distinct_size=4 * countVerses();
  if (bitwise_size <= ranged_size && bitwise_size <= distinct_size) {
    out.writeInt(BITWISE);
    BitSet store=new BitSet(bitwise_size);
    for (    Key aKey : this) {
      Verse verse=(Verse)aKey;
      store.set(v11n.getOrdinal(verse) - 1);
    }
    out.writeObject(store);
  }
 else   if (distinct_size <= ranged_size) {
    out.writeInt(DISTINCT);
    out.writeInt(countVerses());
    for (    Key aKey : this) {
      Verse verse=(Verse)aKey;
      out.writeInt(v11n.getOrdinal(verse));
    }
  }
 else {
    out.writeInt(RANGED);
    out.writeInt(countRanges(RestrictionType.NONE));
    Iterator<Key> it=rangeIterator(RestrictionType.NONE);
    while (it.hasNext()) {
      VerseRange range=(VerseRange)it.next();
      out.writeInt(v11n.getOrdinal(range.getStart()));
      out.writeInt(range.getCardinality());
    }
  }
}