From cf9f98acbf30ed23e217d975e53ecd6ac47a3412 Mon Sep 17 00:00:00 2001 From: richie Date: Thu, 1 Aug 2019 19:31:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- native/mylib/src/lib.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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; +}