private final void writeDebugInfo(int classId, int tag) {
    if (!Debug.COMMUNICATIONS || !getCheckCommunications()) throw new IllegalStateException();

    if (Debug.COMMUNICATIONS_LOG_ALL) {
      String name = ImmutableClass.ALL.get(classId).toString();
      Log.write(
          PlatformClass.getSimpleName(getClass())
              + ", "
              + ThreadAssert.getOrCreateCurrent().getWriterDebugCounter(this)
              + ", class: "
              + name
              + ", tag: "
              + tag);
    }

    Debug.assertion(classId == Helper.getInstance().getExpectedClass());
    long debugCounter = ThreadAssert.getOrCreateCurrent().getAndIncrementWriterDebugCounter(this);
    writeLongToBuffer(debugCounter);
    writeByteToBuffer((byte) classId);
    writeIntegerToBuffer(tag);
    writeIntegerToBuffer(getCustomDebugInfo1());
    writeIntegerToBuffer(getCustomDebugInfo2());
  }
 void reset() {
   if (Debug.COMMUNICATIONS && getCheckCommunications())
     ThreadAssert.getOrCreateCurrent().resetWriterDebugCounter(this);
 }