From 27abc2bf6a8189ecdf8f8cce38f27adb652990c8 Mon Sep 17 00:00:00 2001 From: xiaozhou233 Date: Mon, 17 Aug 2026 20:04:40 +0800 Subject: [PATCH] Fix: propagate preload/init failure from JNI init entry Java_cn_xiaozhou233_juiceagent_api_JuiceAgent_init now checks the return values of Agent::preload and Agent::init and returns JNI_FALSE when either fails, instead of always reporting success to Java. --- src/libagent/entry/jni.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libagent/entry/jni.cpp b/src/libagent/entry/jni.cpp index d9cdfe9..e1c512a 100644 --- a/src/libagent/entry/jni.cpp +++ b/src/libagent/entry/jni.cpp @@ -44,8 +44,14 @@ JNIEXPORT jboolean JNICALL Java_cn_xiaozhou233_juiceagent_api_JuiceAgent_init // Invoke EntryPoint JuiceAgent::Agent& agent = JuiceAgent::Agent::getInstance(); - agent.preload(jvm, env, jvmti, runtime_dir); - agent.init(); + if (!agent.preload(jvm, env, jvmti, runtime_dir)) { + spdlog::error("Failed to preload JuiceAgent"); + return JNI_FALSE; + } + if (!agent.init()) { + spdlog::error("Failed to init JuiceAgent"); + return JNI_FALSE; + } return JNI_TRUE; } \ No newline at end of file