Interconnecting Java and Native Code with the FFM API
summary
Shows how Java SE 22’s Foreign Function & Memory API models off‑heap buffers as a memory segment, enforces bounds and deterministic deallocation via arena lifetimes, and describes native functions with var handles and downcall handle descriptors so calling C is pure Java. Demonstrations include invoking getpid, passing C strings, qsort with a Java comparator via a callback, and using jextract to auto‑generate bindings for OpenGL TensorFlow and FFmpeg. Performance equals JNI for calls and often beats JNI for upcalls.
AI-written summary · about
chapters (10)
- 0:00Introduction to FFM
- 2:08JNI limitations
- 6:49Memory segments
- 10:21Memory safety with arenas
- 17:42Memory layouts
- 22:38Foreign function API
- 25:07Using jextract
- 27:57Live coding demonstration
- 36:42API evolution
- 40:23Summary and Q&A
related talks
51mNative Interoperability with JDK 25 and the FFM API
49mWhen a Java Programmer Meets C
16mForeign Function and Memory API
01h 01mJava Enable Preview: Foreign Function and Memory Interface
55mBare metal Java
47mFFM API — Nothing to Do with Radio
01h 01mNative Code, Off-Heap Data and Java
33mFrom native code gems to Java treasures with jextract
