public final void writeCompactLength(int len) {
    byte b = (byte)(len & 0x7F);
    if (len <= 0x7F) {
      writeU8(b);
    } else {
      writeU8(b | 0x80);
      b = (byte)(len >> 7 & 0x7F);
      if (len <= 0x3FFF) {
        writeU8(b);
      } else {
        writeU8(b | 0x80);
        writeU8(len >> 14 & 0xFF);
      }
    }
  }