A template project for setting up both Rust and the Java 18 Panama Foreign Linker API (via jextract).
How to Setup
- Clone the repo.
- Modify the values in
gradle.propertiesto your liking.
- You're done!
Rust has limited support in the Java ecosystem, and as such, deserves to have some attention (especially since it's a very nice and fast language). Due to the difficulty of interfacing with a native application like Cargo, the template uses a Gradle plugin called
gradle-cargo-wrapper that runs Cargo via Gradle's
Exec task type.
Read more about Rust:
Project Panama (shortened to just Panama) is an upcoming collection of Java features designed to enhance performance safely.
Currently, Panama includes 3 major APIs:
These all work with low-level concepts, like memory, and are very efficient.
The main API we are looking at for this template is the Foreign Linker, as it allows for a high-speed alternative to JNI (Java Native Interface), which is what allows us to interface with functions in native languages, like C or Rust.
The Foreign Linker is quite complicated by itself, but thankfully a tool was created to automatically generate the required bindings for a C header file. This tool is called
jextract and is used by this template.