From native code gems to Java treasures with jextract
AnaMariaMihalceanu1
192 views
9 slides
Oct 06, 2024
Slide 1 of 9
1
2
3
4
5
6
7
8
9
About This Presentation
When developing a Java application, there can be use cases when you need access to system-level APIs and libraries written in other programming languages ( C, OpenGL, Tensorflow, Rust, Python, etc.). Project Panama is designed to facilitate access to native libraries, particularly those developed in...
When developing a Java application, there can be use cases when you need access to system-level APIs and libraries written in other programming languages ( C, OpenGL, Tensorflow, Rust, Python, etc.). Project Panama is designed to facilitate access to native libraries, particularly those developed in C/C++, from Java code.
Interaction between the JVM and the "foreign" (non-Java) APIs has been made simpler with Foreign Function and Memory API (FFM API). The FFM API became a final feature in JDK 22, and it comes with a little gem - the jextract tool - that can automate obtaining access to native code. jextract parses header files (.h) of native libraries and generates Java code, named bindings that use the FFM API internally.
Size: 913.05 KB
Language: en
Added: Oct 06, 2024
Slides: 9 pages
Slide Content
From native code gems to Java
treasures with jextract
Hello! I am Ana
What problem do we aim to solve?
System APIs (Bluetooth, USB)
Machine Learning (ONNX, Tensorflow)
Off-CPU computing (Cuda, OpenCL)
Graphics processing (OpenGL, Vulkan, DirectX)
Others (CRIU, fuse, OpenSSL, V8, ucx)
can be
Foreign function and memory API workflow
Automate generating FFM bindings with jextract
Let’s see it in action!
A substrate for native access in the JVM
Foreign function and memory API adoption
Useful links
•Try the FFM API in JDK 23!
•https://jdk.java.net/23/
•Subscribe to [email protected] and send feedback!
•Generate FFM bindings with the jextract tool
•https://jdk.java.net/jextract/
•jextract guide: https://github.com/openjdk/jextract/blob/master/doc/GUIDE.md
•Checkout examples:
•jextract samples: https://github.com/openjdk/jextract/tree/master/samples
•Calling a rust library with the Panama FFI
•Build the latest version of the FFM API & jextract
•https://github.com/openjdk/panama-foreign
•https://github.com/openjdk/jextract