A live-coding talk covering the Foreign Function and Memory (FFM) API finalized in JDK 22+, demonstrated with JDK 25. The presenter walks through the problems with legacy approaches (ByteBuffer, JNI, Unsafe) and shows how MemorySegment, Arena lifecycle management, MemoryLayout, and VarHandles provide safe, deterministic, and efficient access to native and heap memory. Key topics include confined vs. shared arenas, thread confinement, struct-like layouts, multi-dimensional sequence layouts, atomic operations with alignment enforcement, and calling native functions directly from Java without writing C shim code. The JExtract tool is introduced as a way to auto-generate Java bindings from C header files, with an ONNX inference example demonstrating end-to-end native library integration.
Sort: