Xuanwo commented on code in PR #2112:
URL:
https://github.com/apache/incubator-opendal/pull/2112#discussion_r1176258746
##########
bindings/java/src/lib.rs:
##########
@@ -15,20 +15,29 @@
// specific language governing permissions and limitations
// under the License.
+use std::cell::RefCell;
use std::collections::HashMap;
use std::str::FromStr;
+use std::sync::Arc;
-use jni::objects::JClass;
use jni::objects::JMap;
use jni::objects::JObject;
use jni::objects::JString;
+use jni::objects::{JClass, JValue};
use jni::sys::jboolean;
use jni::sys::jlong;
-use jni::JNIEnv;
+use jni::{JNIEnv, JavaVM};
+use tokio::runtime::{Builder, Runtime};
+
use opendal::BlockingOperator;
use opendal::Operator;
use opendal::Scheme;
+thread_local! {
Review Comment:
Maybe we can refer to
https://github.com/jni-rs/jni-rs/blob/master/example/mylib/src/lib.rs#L145?
##########
bindings/java/src/lib.rs:
##########
@@ -45,7 +54,29 @@ pub extern "system" fn
Java_org_apache_opendal_Operator_getOperator(
let map = convert_map(&mut env, ¶ms);
if let Ok(operator) = build_operator(scheme, map) {
- Box::into_raw(Box::new(operator)) as jlong
+ let java_vm = Arc::new(env.get_java_vm().unwrap());
+ let runtime = Builder::new_multi_thread()
Review Comment:
It's not a good idea to me that building a new runtime for every operator.
Do we have a better choice?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]