1use std::os::raw::c_void;
2
3use crate::errors;
17use jni_sys::{jclass, jint, jobject, jsize, JNIEnv, JavaVM};
18
19#[cfg(all(not(feature = "no-runtime-libloading"), not(target_os = "android")))]
20mod generic;
21
22#[cfg(all(not(feature = "no-runtime-libloading"), not(target_os = "android")))]
23pub fn get_created_java_vms(
24 vm_buf: &mut Vec<*mut JavaVM>,
25 buf_len: jsize,
26 n_vms: *mut jsize,
27) -> jint {
28 generic::get_created_java_vms(vm_buf, buf_len, n_vms)
29}
30
31#[cfg(all(not(feature = "no-runtime-libloading"), not(target_os = "android")))]
32pub fn set_java_vm(_: *mut JavaVM) {}
33
34#[cfg(all(not(feature = "no-runtime-libloading"), not(target_os = "android")))]
35pub fn create_java_vm(pvm: *mut *mut JavaVM, penv: *mut *mut c_void, args: *mut c_void) -> jint {
36 generic::create_java_vm(pvm, penv, args)
37}
38
39#[cfg(all(not(feature = "no-runtime-libloading"), not(target_os = "android")))]
40pub fn find_class(env: *mut JNIEnv, classname: &str) -> errors::Result<jclass> {
41 generic::find_class(env, classname)
42}
43
44#[cfg(all(not(feature = "no-runtime-libloading"), not(target_os = "android")))]
45pub fn cache_classloader_of(_env: *mut JNIEnv, _obj: jobject) -> errors::Result<()> {Ok(())}
46#[cfg(all(feature = "no-runtime-libloading", not(target_os = "android")))]
49mod no_runtime_lib_loading;
50
51#[cfg(all(feature = "no-runtime-libloading", not(target_os = "android")))]
52pub fn get_created_java_vms(
53 vm_buf: &mut Vec<*mut JavaVM>,
54 buf_len: jsize,
55 n_vms: *mut jsize,
56) -> jint {
57 no_runtime_lib_loading::get_created_java_vms(vm_buf, buf_len, n_vms)
58}
59
60#[cfg(all(feature = "no-runtime-libloading", not(target_os = "android")))]
61pub fn set_java_vm(_: *mut JavaVM) {}
62
63#[cfg(all(feature = "no-runtime-libloading", not(target_os = "android")))]
64pub fn create_java_vm(pvm: *mut *mut JavaVM, penv: *mut *mut c_void, args: *mut c_void) -> jint {
65 no_runtime_lib_loading::create_java_vm(pvm, penv, args)
66}
67
68#[cfg(all(feature = "no-runtime-libloading", not(target_os = "android")))]
69pub fn find_class(env: *mut JNIEnv, classname: &str) -> errors::Result<jclass> {
70 no_runtime_lib_loading::find_class(env, classname)
71}
72
73#[cfg(all(feature = "no-runtime-libloading", not(target_os = "android")))]
74pub fn cache_classloader_of(_env: *mut JNIEnv, _obj: jobject) -> errors::Result<()> {Ok(())}
75#[cfg(target_os = "android")]
78mod android;
79
80#[cfg(target_os = "android")]
81pub fn get_created_java_vms(
82 vm_buf: &mut Vec<*mut JavaVM>,
83 buf_len: jsize,
84 n_vms: *mut jsize,
85) -> jint {
86 android::get_created_java_vms(vm_buf, buf_len, n_vms)
87}
88
89#[cfg(target_os = "android")]
90pub fn set_java_vm(java_vm: *mut JavaVM) {
91 android::set_java_vm(java_vm);
92}
93
94#[cfg(target_os = "android")]
95pub fn create_java_vm(pvm: *mut *mut JavaVM, penv: *mut *mut c_void, args: *mut c_void) -> jint {
96 android::create_java_vm(pvm, penv, args)
97}
98
99#[cfg(target_os = "android")]
100pub fn find_class(env: *mut JNIEnv, classname: &str) -> errors::Result<jclass> {
101 android::find_class(env, classname)
102}
103
104#[cfg(target_os = "android")]
105pub fn cache_classloader_of(env: *mut JNIEnv, obj: jobject) -> errors::Result<()> {
106 android::cache_classloader_of(env, obj)
107}