wrap static method

JByteBuffer wrap(
  1. JArray<jbyte> array, [
  2. int? offset,
  3. int? length
])

Wraps a byte array into a buffer.

The new buffer will be backed by the given byte array; that is, modifications to the buffer will cause the array to be modified and vice versa.

Implementation

static JByteBuffer wrap(
  JArray<jbyte> array, [
  int? offset,
  int? length,
]) {
  if (offset == null && length == null) {
    return _wrapWholeId(
      _class,
      const JByteBufferType(),
      [array.reference.pointer],
    );
  }
  offset ??= 0;
  length ??= array.length - offset;
  return _wrapId(
    _class,
    const JByteBufferType(),
    [array.reference.pointer, JValueInt(offset), JValueInt(length)],
  );
}