Impl: retransform

This commit is contained in:
xiaozhou233 committed 2026-04-02 14:19:13 +08:00
1 parent 5e7972779f
commit f73265ac3e
5 files changed
+185 -1

No files matched your search

+28
View File
@@ -12,4 +12,32 @@ inline bool check_env(JuiceAgent::Agent& agent) {
return false;
}
return true;
}
inline std::string get_class_name(JNIEnv* env, jclass clazz) {
if (!env || !clazz) return "";
jclass clsClass = env->FindClass("java/lang/Class");
if (!clsClass) return "";
jmethodID mid = env->GetMethodID(clsClass, "getName", "()Ljava/lang/String;");
if (!mid) {
env->DeleteLocalRef(clsClass);
return "";
}
jstring nameStr = static_cast<jstring>(env->CallObjectMethod(clazz, mid));
std::string result;
if (nameStr) {
const char* tmp = env->GetStringUTFChars(nameStr, nullptr);
if (tmp) {
result = tmp; // copy to std::string
env->ReleaseStringUTFChars(nameStr, tmp);
}
env->DeleteLocalRef(nameStr);
}
env->DeleteLocalRef(clsClass);
return result;
}