diff --git a/native/mylib/src/lib.rs b/native/mylib/src/lib.rs index c886a8c..8606502 100644 --- a/native/mylib/src/lib.rs +++ b/native/mylib/src/lib.rs @@ -9,7 +9,9 @@ use jni::objects::{JClass, JString}; // This is just a pointer. We'll be returning it from our function. We // can't return one of the objects with lifetime information because the // lifetime checker won't let us. -use jni::sys::jstring; +use jni::sys::{jstring, jint}; + +use std::any::Any; // This keeps rust from "mangling" the name and making it unique for this // crate. #[no_mangle] @@ -33,4 +35,10 @@ pub extern "system" fn Java_HelloWorld_hello(env: JNIEnv, .expect("Couldn't create java string!"); // Finally, extract the raw pointer to return. output.into_inner() -} \ No newline at end of file +} + +#[no_mangle] +#[allow(non_snake_case)] +pub extern "system" fn Java_MyMath_add(env: JNIEnv, class: JClass, a: jint, b: jint) -> jint { + return a + b; +}