34
34
import java .io .RandomAccessFile ;
35
35
import java .nio .MappedByteBuffer ;
36
36
import java .nio .channels .FileChannel ;
37
+ import static java .nio .channels .FileChannel .MapMode .*;
37
38
38
39
/**
39
40
* @author Tomas Hurka
@@ -433,7 +434,7 @@ public void putLong(long index, long data) {
433
434
434
435
@ Override
435
436
public void force () throws IOException {
436
- if (MAP_MODE == FileChannel . MapMode . PRIVATE ) {
437
+ if (MAP_MODE == PRIVATE ) {
437
438
File newBufferFile = new File (bufferFile .getAbsolutePath ()+".new" ); // NOI18N
438
439
int length = buf .capacity ();
439
440
new FileOutputStream (newBufferFile ).getChannel ().write (buf );
@@ -455,12 +456,12 @@ private static MappedByteBuffer createBuffer(RandomAccessFile file, long length)
455
456
private static FileChannel .MapMode computeMapMode () {
456
457
String mode = System .getProperty ("org.graalvm.visualvm.lib.jfluid.heap.mapmode" ); // NOI18N
457
458
if (mode != null ) {
458
- if ("private" .equals (mode )) return FileChannel . MapMode . PRIVATE ; // NOI18N
459
- return FileChannel . MapMode . READ_WRITE ;
459
+ if ("private" .equals (mode )) return PRIVATE ; // NOI18N
460
+ return READ_WRITE ;
460
461
}
461
- if (isLinux ()) return FileChannel . MapMode . PRIVATE ;
462
- if (isMacOS () && isAarch64 ()) return FileChannel . MapMode . PRIVATE ;
463
- return FileChannel . MapMode . READ_WRITE ;
462
+ if (isLinux ()) return PRIVATE ;
463
+ if (isMacOS () && isAarch64 ()) return PRIVATE ;
464
+ return READ_WRITE ;
464
465
}
465
466
}
466
467
@@ -522,7 +523,7 @@ private int getBufferOffset(long index) {
522
523
523
524
@ Override
524
525
public void force () throws IOException {
525
- if (MemoryMappedData .MAP_MODE == FileChannel . MapMode . PRIVATE ) {
526
+ if (MemoryMappedData .MAP_MODE == PRIVATE ) {
526
527
File newBufferFile = new File (bufferFile .getAbsolutePath ()+".new" ); // NOI18N
527
528
long length = bufferFile .length ();
528
529
try (FileChannel channel = new FileOutputStream (newBufferFile ).getChannel ()) {
0 commit comments