Skip to main content

block_on_jni

Function block_on_jni 

Source
pub fn block_on_jni<T: Send + 'static>(
    env: &mut JNIEnv<'_>,
    _context: &str,
    fut: impl Future<Output = T> + Send + 'static,
) -> Option<T>
Expand description

Block on a future from a JNI entry point, panic-safe.

  • If a Tokio runtime is already active on this thread, fut is polled to completion inside that runtime (spawn + block_on the JoinHandle).
  • Otherwise the future runs on the process-wide JNI runtime.
  • Any panic inside fut is caught and re-thrown to Java as a com.dunimd.ri.RiError instead of aborting the JVM.

Returns None when a panic was caught (a Java exception is pending).