As a Java developer, you may have a need to access native libraries, such as Tensorflow, SqlLite, ffmpeg, OpenGL, but later find that JNI is your default choice. JNI (Java Native Interface) requires native code to be installed. You’ll quickly find that JNI wrapper code is difficult to maintain.
New to OpenJDK 17 is the Foreign Linker API (JEP 412) as a replacement or alternative for JNI to provide a pure-Java solution and perform comparable to, or better than, JNI.
The aim of this talk is to help you be proficient at creating Java programs capable of accessing devices and/or native libraries mainly focussing on OpenJDK 17’s Foreign Linker API.
Intro (what, why, where)
Requirements
IDE, environment setup
Getting started
Anatomy of a Hello World in C
What is jextract
Panama Hello World in Java
How to allocate memory to work with C primitives, arrays, & C strings.
How to allocate and mimic pointers, structs, and array of structs.
What are VarHandles?
What are MethodHandles?
Using super powers to access system libraries
Using super powers to access third party libraries (demos)
Demos may include: OpenGL, Tensorflow, Git, ffmpeg, Python, Rust, Swift, MacOS touchID,
MacOS SpeechSynthesizer.
Carl Dea is a Sr. developer advocate at AzulSystems inc. He has authored Java books and has been developing software for 20+ years with many clients, from Fortune 500 companies to nonprofit organizations. He has written software ranging from mission-critical applications to e-commerce applications. Carl has been using Java since the very beginning (when Applets were cool) and is a JavaFX enthusiast (fanboy) dating back to when it used to be called F3/JavaFX Script. He greatly loves sharing and advocating Java based technologies.