@@ -205,6 +205,18 @@ private static boolean isLinux() {
205
205
return osName .endsWith ("Linux" ); // NOI18N
206
206
}
207
207
208
+ private static boolean isMacOS () {
209
+ String osName = System .getProperty ("os.name" ); // NOI18N
210
+
211
+ return "Mac OS X" .equals (osName ); // NOI18N
212
+ }
213
+
214
+ private static boolean isAarch64 () {
215
+ String osArch = System .getProperty ("os.arch" ); // NOI18N
216
+
217
+ return "aarch64" .equals (osArch ); // NOI18N
218
+ }
219
+
208
220
abstract Entry createEntry (long index );
209
221
210
222
abstract Entry createEntry (long index ,long value );
@@ -379,7 +391,7 @@ public void force() throws IOException {
379
391
380
392
private static class MemoryMappedData extends AbstractData {
381
393
382
- private static final FileChannel .MapMode MAP_MODE = isLinux () ? FileChannel . MapMode . PRIVATE : FileChannel . MapMode . READ_WRITE ;
394
+ private static final FileChannel .MapMode MAP_MODE = computeMapMode () ;
383
395
384
396
//~ Instance fields ------------------------------------------------------------------------------------------------------
385
397
@@ -439,6 +451,12 @@ private static MappedByteBuffer createBuffer(RandomAccessFile file, long length)
439
451
return channel .map (MAP_MODE , 0 , length );
440
452
}
441
453
}
454
+
455
+ private static FileChannel .MapMode computeMapMode () {
456
+ if (isLinux ()) return FileChannel .MapMode .PRIVATE ;
457
+ if (isMacOS () && isAarch64 ()) return FileChannel .MapMode .PRIVATE ;
458
+ return FileChannel .MapMode .READ_WRITE ;
459
+ }
442
460
}
443
461
444
462
private static class LongMemoryMappedData extends AbstractData {
0 commit comments