Java Cup
Inside Java

News and views from members of the Java team at Oracle

JVMLS - Foreign Function & Memory API

(Recorded at JVMLS 2023 - for more, check our JVMLS 2023 playlist.)

Maurizio Cimadamore explores how Project Panama's Foreign Function & Memory API lets Java programs work with native libraries and off-heap memory. He contrasts its Java-first approach with JNI and direct buffers, then explains memory segments, arenas, and layouts for managing lifetimes and accessing structured data safely.

The presentation shows how the native linker connects Java and C through downcalls and callbacks, including platform-specific calling conventions and memory allocated by native code. Examples illustrate restricted operations and their safety limits, while jextract demonstrates how generated bindings can replace repetitive setup code without requiring handwritten JNI glue.

Additional Resources