code: public int writeShort(OutputStream dest, int id, Object obj) throws IOException {
          int idx;
  
          idx = addIfNew(id, obj);
          if (idx >>> 8 != 0) {
              throw new RuntimeException("idx not short " + idx);
          }
          IO.writeU1(dest, idx);
          return idx;
      }
docs: the id and and int id is easier to handle than a reference.