update at 2022-02-22 20:29:33 by ehlxr

This commit is contained in:
2022-02-22 20:29:33 +08:00
commit f624b2eb80
6 changed files with 252 additions and 0 deletions

21
mylib/src/lib.rs Normal file
View File

@@ -0,0 +1,21 @@
use jni::objects::{JClass, JString};
use jni::sys::jstring;
use jni::JNIEnv;
#[no_mangle]
pub extern "system" fn Java_me_ehlxr_HelloWorld_hello(
env: JNIEnv,
_class: JClass,
input: JString,
) -> jstring {
let input: String = env
.get_string(input)
.expect("Couldn't get java string!")
.into();
let output = env
.new_string(format!("Hello, {}! from Rust...111", input))
.expect("Couldn't create java string!");
output.into_inner()
}