diff --git a/pom.xml b/pom.xml
index 52f7483d..065d3c2f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -47,8 +47,8 @@
lines,vars,source
false
true
-
- 20
+
+ 21
UTF-8
--enable-preview
diff --git a/src/main/java/org/nustaq/offheap/bytez/malloc/MMFBytez.java b/src/main/java/org/nustaq/offheap/bytez/malloc/MMFBytez.java
index 036ba734..2a2b6525 100644
--- a/src/main/java/org/nustaq/offheap/bytez/malloc/MMFBytez.java
+++ b/src/main/java/org/nustaq/offheap/bytez/malloc/MMFBytez.java
@@ -19,7 +19,7 @@
import java.io.RandomAccessFile;
import java.io.File;
-import java.lang.foreign.SegmentScope;
+import java.lang.foreign.Arena;
import java.nio.channels.FileChannel;
/**
@@ -28,7 +28,7 @@
*/
public class MMFBytez extends MemoryBytez {
private File file;
- private SegmentScope scope;
+ private Arena scope;
public MMFBytez(String filePath, long length, boolean clearFile) throws Exception {
init(filePath, length, clearFile);
@@ -44,7 +44,7 @@ protected void init(String file, long length, boolean clearFile) throws Exceptio
f.createNewFile();
}
- scope = SegmentScope.auto();
+ scope = Arena.ofAuto();
memseg = new RandomAccessFile(f, "rw").getChannel().map(FileChannel.MapMode.READ_WRITE, 0, length, scope);
/// memseg = MemorySegment.mapFile(f.toPath(), 0, length, FileChannel.MapMode.READ_WRITE, scope);
this.file = f;
diff --git a/src/main/java/org/nustaq/offheap/bytez/malloc/MemoryBytez.java b/src/main/java/org/nustaq/offheap/bytez/malloc/MemoryBytez.java
index ee988408..c7624047 100644
--- a/src/main/java/org/nustaq/offheap/bytez/malloc/MemoryBytez.java
+++ b/src/main/java/org/nustaq/offheap/bytez/malloc/MemoryBytez.java
@@ -20,9 +20,6 @@
import org.nustaq.offheap.bytez.BasicBytez;
import org.nustaq.offheap.bytez.Bytez;
-import java.lang.invoke.VarHandle;
-import java.nio.ByteOrder;
-
/**
* Date: 17.11.13
* Time: 00:01
@@ -37,7 +34,9 @@ public class MemoryBytez implements Bytez {
protected MemoryBytez() {}
public MemoryBytez(long len) {
- memseg = MemorySegment.allocateNative(len, SegmentScope.auto());
+ try (Arena arena = Arena.ofConfined()) {
+ memseg = arena.allocate(len);
+ }
}
public MemoryBytez(MemorySegment mem) {