code: public static void checkOffsetAndCount(final byte[] buffer, final int byteOffset,
        final int byteCount) {
      // Ensure we throw a NullPointerException instead of a JavascriptException in case the
      // given buffer is null.
      if (buffer == null) {
        throw new NullPointerException();
      }
      checkOffsetAndCount(buffer.length, byteOffset, byteCount);
    }
docs: Validates the offset and the byte count for the given array of bytes.
  
  @param buffer Array of bytes to be checked.
  @param byteOffset Starting offset in the array.
  @param byteCount Total number of bytes to be accessed.
  @throws NullPointerException if the given reference to the buffer is null.
  @throws IndexOutOfBoundsException if {@code byteOffset} is negative, {@code byteCount} is
  negative or their sum exceeds the buffer length.