12 Foreign Function and Memory API
The Foreign Function and Memory (FFM) API enables Java programs to interoperate with code and data outside the Java runtime. This API enables Java programs to call native libraries and process native data without the brittleness and danger of JNI. The API invokes foreign functions, code outside the JVM, and safely accesses foreign memory, memory not managed by the JVM.
For background information about the FFM API, see JEP 454.
The FFM API is contained in the package java.lang.foreign.
Topics
- On-Heap and Off-Heap Memory
- Memory Segments and Arenas
- Calling a C Library Function with the Foreign Function and Memory API
- Upcalls: Passing Java Code as a Function Pointer to a Foreign Function
- Foreign Functions That Return Pointers
- Memory Layouts and Structured Access
- Checking for Native Errors Using errno
- Slicing Allocators and Slicing Memory Segments
- Restricted Methods
- Calling Native Functions with jextract