alef 0.25.37

Opinionated polyglot binding generator for Rust libraries
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/// Generated JNI bridge for the `{{ trait_name }}` contract.
///
/// Wraps a global JVM reference to a Java handler object so it can be used
/// as `Arc<dyn {{ trait_name }}>` from Rust async code.
pub struct {{ bridge_name }} {
    /// Global JVM reference to the Java handler object.
    global_ref: jni::objects::GlobalRef,
    /// The JavaVM pointer for thread attachment.
    jvm: jni::JavaVM,
    /// Method ID for the dispatch method (cached for performance).
    method_id: jni::sys::jmethodID,
}

// SAFETY: GlobalRef is Send+Sync once obtained in JVM context.
// JavaVM is Send+Sync per jni crate semantics (one global VM per process).
// jmethodID is stable for the method lifetime.
unsafe impl Send for {{ bridge_name }} {}
unsafe impl Sync for {{ bridge_name }} {}