jnix
This crate provides high-level extensions to help with the usage of JNI in Rust code. Internally,
it uses the jni-rs
crate for the low-level JNI operations.
Some helper traits are provided, such as:
AsJValue
: for allowing a JNI type to be convected to aJValue
wrapper type.IntoJava
: for allowing a Rust type to be converted to a Java type.
A JnixEnv
helper type is also provided, which is a JNIEnv
wrapper that contains an
internal class cache for preloaded classes.
If compiled with the derive
feature flag, the crate also exports a derive procedural macro
for IntoJava
, which allows writing conversion code a lot easier.
An example would be:
use ;
// Rust type definition
// A JNI function called from Java that creates a `MyData` Rust type, converts it to a Java
// type and returns it.
pub extern "system"
;