MCPcopy Create free account
hub / github.com/astonbitecode/j4rs / find_class_using_cached_classloader

Function find_class_using_cached_classloader

rust/src/api_tweaks/android.rs:127–149  ·  view source on GitHub ↗
(
    env: *mut JNIEnv,
    classname: &str,
)

Source from the content-addressed store, hash-verified

125}
126
127unsafe fn find_class_using_cached_classloader(
128 env: *mut JNIEnv,
129 classname: &str,
130) -> errors::Result<jclass> {
131 let g = CLASSLOADER.lock()?;
132 if g.is_some() {
133 let cstr = jni_utils::local_jobject_from_str(classname, env).unwrap();
134 let classloader_instance = g.as_ref().unwrap().class_loader;
135 let found = cache::get_jni_call_object_method().unwrap()(
136 env,
137 classloader_instance,
138 cache::get_load_class_method().unwrap(),
139 cstr,
140 );
141
142 let found = do_return(env, found, classname);
143 found
144 } else {
145 Err(errors::J4RsError::JavaError(format!(
146 "Class not found {classname}"
147 )))
148 }
149}
150
151fn do_return<T>(jni_env: *mut JNIEnv, to_return: T, message: &str) -> errors::Result<T> {
152 unsafe {

Callers 1

find_classFunction · 0.85

Calls 4

local_jobject_from_strFunction · 0.85
get_load_class_methodFunction · 0.85
do_returnFunction · 0.85

Tested by

no test coverage detected