docs: private void ensureCapacity(final int index, final int length)
      {
          if (index < 0)
          {
              throw new IndexOutOfBoundsException("index cannot be negative: index=" + index);
          }
  
          final long resultingPosition = index + (long)length;
          final int currentCapacity = capacity;
          if (resultingPosition > currentCapacity)
          {
              if (currentCapacity >= MAX_BUFFER_LENGTH)
              {
                  throw new IndexOutOfBoundsException(
                      "index=" + index + " length=" + length + " maxCapacity=" + MAX_BUFFER_LENGTH);
              }
  
              final int newCapacity = calculateExpansion(currentCapacity, (int)resultingPosition);
              final ByteBuffer newBuffer = ByteBuffer.allocateDirect(newCapacity);
  
              getBytes(0, newBuffer, 0, capacity);
  
              address = address(newBuffer);
              capacity = newCapacity;
              byteBuffer = newBuffer;
          }
      }