in datasketches-memory-java8/src/main/java/org/apache/datasketches/memory/internal/AllocateDirectWritableMap.java [238:254]
private static long map(final FileChannel fileChannel, final boolean resourceReadOnly,
final long position, final long lengthBytes) {
final int pagePosition = (int) (position % unsafe.pageSize());
final long mapPosition = position - pagePosition;
final long mapSize = lengthBytes + pagePosition;
final int mapMode = resourceReadOnly ? MAP_RO : MAP_RW;
//final boolean isSync = true; //required as of JDK14, but it is more complex
try {
final long nativeBaseOffset = //JDK14 add isSync
(long) FILE_CHANNEL_IMPL_MAP0_METHOD.invoke(fileChannel, mapMode, mapPosition, mapSize);
return nativeBaseOffset;
} catch (final InvocationTargetException e) {
throw new RuntimeException("Exception while mapping", e.getTargetException());
} catch (final IllegalAccessException e) {
throw new RuntimeException("Exception while mapping", e);
}
}