Created
October 15, 2020 12:59
-
-
Save rockey5520/2eba828ce912cc99e26b5d967cfe24be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jdk.incubator.foreign.MemoryAddress; | |
import java.lang.invoke.VarHandle; | |
import jdk.incubator.foreign.MemoryHandles; | |
import java.nio.ByteOrder; | |
import jdk.incubator.foreign.MemorySegment; | |
| |
public class ForeignMemoryAccess { | |
| |
public static void main(String[] args) { | |
| |
VarHandle handle = MemoryHandles.varHandle( | |
int.class, ByteOrder.nativeOrder()); | |
| |
try (MemorySegment segment = MemorySegment.allocateNative(2048)) { | |
MemoryAddress base = segment.baseAddress(); | |
// print memory address | |
System.out.println(base); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment