You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "kidylee (via GitHub)" <gi...@apache.org> on 2023/04/25 13:34:12 UTC

[GitHub] [incubator-opendal] kidylee commented on issue #1572: OpenDAL Java Bindings

kidylee commented on issue #1572:
URL: https://github.com/apache/incubator-opendal/issues/1572#issuecomment-1521800824

   Thanks @ShadowySpirits , looking forward for this feature.
   
   Regard to the approach, I think we need other design to manage thread lifecycle in Rust side, instead of creating it each time when calling native method.
   
   One approach is we can use the ``register`` method when Java loading ``dylib``. You can check this [doc](https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/design.html) here.
   
   >  If a library L is statically linked, then upon the first invocation of System.loadLibrary("L") or equivalent API, a JNI_OnLoad_L function will be invoked with the same arguments and expected return value as specified for the JNI_OnLoad function.
   
   We can create ``tokio`` runtime in this ``OnLoad`` method.
   
   > When the class loader containing a statically linked native library L is garbage collected, the VM will invoke the JNI_OnUnload_L function of the library if such a function is exported.
   
   Same as ``register``, ``tokio runtime`` could be destroyed in ``OnUnload`` method.
   
   
   JVM guaranteed dynamic lib will only be loaded once:
   
   > A library L that is statically linked will prohibit a library of the same name from being loaded dynamically.
   
   
   
   
   


-- 
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: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org