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.
This commit is contained in:
xiaozhou233 committed 2026-08-17 20:04:40 +08:00
1 parent 4f433bc6ee
commit 27abc2bf6a
1 file changed
+8 -2
+8 -2
View File
@@ -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;
}