Feat: migrate libagent from JuiceAgent and port to spdlog

This commit is contained in:
xiaozhou233 committed 2026-08-15 13:13:55 +08:00
1 parent bcc1ecbf0e
commit 1d3755952f
22 files changed
+1727 -12

No files matched your search

@@ -0,0 +1,38 @@
#include <jni_impl.hpp>
#include <event/event_type.hpp>
void JNICALL ClassFileLoadHook(
jvmtiEnv* jvmti_env,
JNIEnv* jni_env,
jclass class_being_redefined,
jobject loader,
const char* name,
jobject protection_domain,
jint class_data_len,
const unsigned char* classbytes,
jint* new_class_data_len,
unsigned char** new_classbytes) {
if (!name) {
spdlog::warn("name is null");
return;
}
auto& agent = JuiceAgent::Agent::instance();
EventClassFileLoadHook event{
.jvmti_env = jvmti_env,
.jni_env = jni_env,
.class_being_redefined = class_being_redefined,
.loader = loader,
.name = name,
.protection_domain = protection_domain,
.class_data_len = class_data_len,
.classbytes = classbytes,
.new_class_data_len = new_class_data_len,
.new_classbytes = new_classbytes
};
agent.get_eventbus().post(event);
agent.get_eventbus().post_mutable(event);
}