Skip to content

Commit 9cdf121

Browse files
authored
log failure reason if JNI_OnLoad fails (#668)
1 parent 0cf8822 commit 9cdf121

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

platform/jvm/src/jni.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static STACK_TRACE_PROVIDER_INVOKE: OnceLock<CachedMethod> = OnceLock::new();
193193
pub(crate) fn initialize_method_handle<
194194
'local,
195195
'other_local,
196-
T: Desc<'local, JClass<'other_local>> + std::fmt::Debug + Copy,
196+
T: Desc<'local, JClass<'other_local>>,
197197
>(
198198
env: &mut JNIEnv<'local>,
199199
class: T,
@@ -204,7 +204,6 @@ pub(crate) fn initialize_method_handle<
204204
let method_id = CachedMethod::new(env, class, method_name, signature);
205205

206206
let Ok(cached_id) = method_id else {
207-
log::error!("failed to resolve {class:?}::{method_name} with signature {signature}");
208207
check_exception(env);
209208
bail!("failed to resolve method");
210209
};
@@ -337,7 +336,10 @@ fn jni_load_inner(vm: &JavaVM) -> anyhow::Result<jint> {
337336

338337
#[no_mangle]
339338
pub extern "system" fn JNI_OnLoad(vm: JavaVM, _: *mut c_void) -> jint {
340-
jni_load_inner(&vm).unwrap_or(JNI_ERR)
339+
initialize_logging();
340+
jni_load_inner(&vm)
341+
.inspect_err(|e| log::error!("JNI_OnLoad failed: {e}"))
342+
.unwrap_or(JNI_ERR)
341343
}
342344

343345
//
@@ -600,8 +602,6 @@ pub extern "system" fn Java_io_bitdrift_capture_CaptureJniLibrary_createLogger(
600602
error_reporter: JObject<'_>,
601603
start_in_sleep_mode: jboolean,
602604
) -> jlong {
603-
initialize_logging();
604-
605605
with_handle_unexpected_or(
606606
|| {
607607
let sdk_directory = PathBuf::from(

0 commit comments

Comments
 (0)