The Foreign Function & Memory API (FFM API), finalized in Java 22 as part of Project Panama, is the modern replacement for JNI. It lets Java code call native functions and allocate native memory safely — entirely in pure Java, without writing a single line of C. The three key abstractions are MemorySegment (a region of memory), Arena (its lifetime manager), and MethodHandle (a callable reference to a native function).
Core FFM API types