pub fn init_with_refs(
java_vm: JavaVM,
context: Global<JObject<'static>>,
loader: Global<JClassLoader<'static>>,
)Available on Android only.
Expand description
Initialize with references to the JVM, context, and class loader.
This is useful when you’re already interacting with jni-rs wrapped objects and want to use
global references to objects for efficiency.
This function will never panic.
§Examples
pub fn android_init(raw_env: *mut c_void, raw_context: *mut c_void) -> Result<(), jni::errors::Error> {
let mut env = unsafe { jni::EnvUnowned::from_raw(raw_env as *mut jni::sys::JNIEnv).unwrap() };
let context = unsafe { JObject::from_raw(raw_context as jni::sys::jobject) };
let loader = env.get_object_class(&context)?.get_class_loader(env)?;
env.with_env(|env| {
rustls_platform_verifier::android::init_with_refs(
env.get_java_vm(),
env.new_global_ref(context)?,
env.new_global_ref(loader)?,
);
});
}