code: private void update(ByteBuffer buffer) {
          int pos = buffer.position();
          int limit = buffer.limit();
          assert (pos <= limit);
          int rem = limit - pos;
          if (rem <= 0)
              return;
          if (buffer instanceof DirectBuffer) {
              adler = updateByteBuffer(adler, ((DirectBuffer)buffer).address(), pos, rem);
          } else if (buffer.hasArray()) {
              adler = updateBytes(adler, buffer.array(), pos + buffer.arrayOffset(), rem);
          } else {
              byte[] b = new byte[rem];
              buffer.get(b);
              adler = updateBytes(adler, b, 0, b.length);
          }
          buffer.position(limit);
      }
docs: Updates the checksum with the bytes from the specified buffer.
  
  The checksum is updated using
  buffer.{@link java.nio.Buffer#remaining() remaining()}
  bytes starting at
  buffer.{@link java.nio.Buffer#position() position()}
  Upon return, the buffer's position will be updated to its
  limit; its limit will not have been changed.
  
  @param buffer the ByteBuffer to update the checksum with