Learning example for Java Arenas and Memory Segments.
A minimal runnable example demonstrating native allocations using an "arena"
is provided in src/main/java/com/bhf/learning/memory/ArenaExample.java.
Requirements:
- JDK with the
java.lang.foreignAPI (tested on JDK 24).
Build and run from the project root using the Gradle wrapper:
# Compile
./gradlew clean build
# Run the example class directly
java -cp build/classes/java/main com.bhf.learning.memory.ArenaExampleExpected output:
Java Arena (MemorySession) example
Written ints (native): 10, 20, 30, 40
Read string (native): Hello Arena
Arena closed — native memory freed.
If your JDK doesn't expose java.lang.foreign.MemorySession (older releases),
the project uses java.lang.foreign.Arena when available; ensure you run with
an appropriate Java version.