in datasketches-memory-java8/src/main/java/org/apache/datasketches/memory/internal/BaseWritableBufferImpl.java [101:111]
WritableBuffer writableRegionImpl(final long offsetBytes, final long capacityBytes,
final boolean localReadOnly, final ByteOrder byteOrder) {
if (isReadOnly() && !localReadOnly) {
throw new ReadOnlyException("Writable region of a read-only Buffer is not allowed.");
}
checkValidAndBounds(offsetBytes, capacityBytes);
final boolean readOnly = isReadOnly() || localReadOnly;
final WritableBuffer wbuf = toWritableRegion(offsetBytes, capacityBytes, readOnly, byteOrder);
wbuf.setStartPositionEnd(0, 0, capacityBytes);
return wbuf;
}