Skip to content

Commit c8dab54

Browse files
committed
use static import for MapMode
1 parent a0ecbc1 commit c8dab54

File tree

1 file changed

+8
-7
lines changed
  • visualvm/libs.profiler/lib.profiler.heap/src/org/graalvm/visualvm/lib/jfluid/heap

1 file changed

+8
-7
lines changed

visualvm/libs.profiler/lib.profiler.heap/src/org/graalvm/visualvm/lib/jfluid/heap/AbstractLongMap.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.io.RandomAccessFile;
3535
import java.nio.MappedByteBuffer;
3636
import java.nio.channels.FileChannel;
37+
import static java.nio.channels.FileChannel.MapMode.*;
3738

3839
/**
3940
* @author Tomas Hurka
@@ -433,7 +434,7 @@ public void putLong(long index, long data) {
433434

434435
@Override
435436
public void force() throws IOException {
436-
if (MAP_MODE == FileChannel.MapMode.PRIVATE) {
437+
if (MAP_MODE == PRIVATE) {
437438
File newBufferFile = new File(bufferFile.getAbsolutePath()+".new"); // NOI18N
438439
int length = buf.capacity();
439440
new FileOutputStream(newBufferFile).getChannel().write(buf);
@@ -455,12 +456,12 @@ private static MappedByteBuffer createBuffer(RandomAccessFile file, long length)
455456
private static FileChannel.MapMode computeMapMode() {
456457
String mode = System.getProperty("org.graalvm.visualvm.lib.jfluid.heap.mapmode"); // NOI18N
457458
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;
460461
}
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;
464465
}
465466
}
466467

@@ -522,7 +523,7 @@ private int getBufferOffset(long index) {
522523

523524
@Override
524525
public void force() throws IOException{
525-
if (MemoryMappedData.MAP_MODE == FileChannel.MapMode.PRIVATE) {
526+
if (MemoryMappedData.MAP_MODE == PRIVATE) {
526527
File newBufferFile = new File(bufferFile.getAbsolutePath()+".new"); // NOI18N
527528
long length = bufferFile.length();
528529
try (FileChannel channel = new FileOutputStream(newBufferFile).getChannel()) {

0 commit comments

Comments
 (0)