docs: @Override
    public final IoBuffer capacity(int newCapacity) {
      if (!recapacityAllowed) {
        throw new IllegalStateException("Derived buffers and their parent can't be expanded.");
      }
  
      // Allocate a new buffer and transfer all settings to it.
      if (newCapacity > capacity()) {
        // Expand:
        // // Save the state.
        int pos = position();
        int limit = limit();
        ByteOrder bo = order();
  
        // // Reallocate.
        ByteBuffer oldBuf = buf();
        ByteBuffer newBuf = getAllocator().allocateNioBuffer(newCapacity, isDirect());
        oldBuf.clear();
        newBuf.put(oldBuf);
        buf(newBuf);
  
        // // Restore the state.
        buf().limit(limit);
        if (mark >= 0) {
          buf().position(mark);
          buf().mark();
        }
        buf().position(pos);
        buf().order(bo);
      }
  
      return this;
    }