code: public static Slice wrappedBuffer(ByteBuffer buffer)
      {
          if (buffer.isDirect()) {
              long address = bufferAddress(buffer);
              return new Slice(null, address + buffer.position(), buffer.remaining(), buffer.capacity(), buffer);
          }
  
          if (buffer.hasArray()) {
              return new Slice(buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining());
          }
  
          throw new IllegalArgumentException("cannot wrap " + buffer.getClass().getName());
      }
docs: Wrap the visible portion of a {@link java.nio.ByteBuffer}.