3 releases

0.1.2 Sep 7, 2023
0.1.1 Sep 7, 2023
0.1.0 Sep 7, 2023

#309 in FFI

47 downloads per month

GPL-3.0 license

20KB
215 lines

Rust function mangler for JNI

Crates.io Docs.rs Build Clippy

The jni-mangle crate provides proc macros for working with Rust functions that are called from Java through JNI.

The main purpose of this crate is to turn rust functions that might look like this:

#[no_mangle]
#[allow(non_snake_case)]
pub extern "system" fn Java_com_example_Example_addTwoNumbers(a: i32, b: i32) -> i32 {
   a + b    
}

Into something a little more readable:

use jni_mangle::mangle;

#[mangle(package="com.example", class="Example", method="addTwoNumbers")]
pub fn add_two_numbers(a: i32, b: i32) -> i32 {
   a + b    
}

Dependencies

~2.8–4.5MB
~79K SLoC