Online / 5 & 6 February 2022

visit

Native Language Access: Project Panama for Newbies


A brief introductory talk on Java 17's New project Panama APIs to get your feet wet into the world of native language access or better known as Foreign Function Interface APIs (JEP 412).

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 your super powers to access system libraries

  • Using your super powers to access third party libraries (demos)
 Demos may include: OpenGL, LeapMotion device, Git, ffmpeg, Python, Swift, MacOS touchID, MacOS SpeechSynthesizer.

All Code will be available online at https://github.com/carldea/panama4newbies

Speakers

Photo of Carl Dea Carl Dea

Links