update at 2022-02-23 20:37:36 by ehlxr

This commit is contained in:
2022-02-23 20:37:36 +08:00
parent ed1ac08fe6
commit 53521e036f
2 changed files with 53 additions and 19 deletions

View File

@@ -1,11 +1,27 @@
use jni::JNIEnv;
use jni::objects::{GlobalRef, JClass, JObject, JString};
use jni::objects::{GlobalRef, JClass, JObject, JString, JValue};
use jni::sys::{jbyteArray, jint, jlong, jstring};
use jni::JNIEnv;
use std::{sync::mpsc, thread, time::Duration};
#[no_mangle]
pub extern "system" fn Java_me_ehlxr_HelloWorld_fetchNameStr(
env: JNIEnv,
_class: JClass,
input: JObject,
) -> jstring {
if let JValue::Object(rt) = env
.call_method(input, "getNameStr", "()Ljava/lang/String;", &[])
.unwrap()
{
println!("return {:?}", rt)
};
let output = env
.new_string(format!("Hello, {:?}! from Rust..", input))
.expect("Couldn't create java string!");
output.into_inner()
}
#[no_mangle]
pub extern "system" fn Java_me_ehlxr_HelloWorld_hello(
env: JNIEnv,