(
env: *mut JNIEnv,
classname: &str,
)
| 125 | } |
| 126 | |
| 127 | unsafe 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 | |
| 151 | fn do_return<T>(jni_env: *mut JNIEnv, to_return: T, message: &str) -> errors::Result<T> { |
| 152 | unsafe { |
no test coverage detected