Commit 4192be5a authored by swift_gan's avatar swift_gan

compile callOriginMethod to avoid CheckIncompatibleClassChange after JIT

parent a4fc9bec
...@@ -269,6 +269,21 @@ Java_com_swift_sandhook_SandHook_ensureMethodDeclaringClass(JNIEnv *env, jclass ...@@ -269,6 +269,21 @@ Java_com_swift_sandhook_SandHook_ensureMethodDeclaringClass(JNIEnv *env, jclass
ensureMethodDeclaringClass(origin, backup); ensureMethodDeclaringClass(origin, backup);
} }
extern "C"
JNIEXPORT void JNICALL
Java_com_swift_sandhook_SandHook_compileMethod(JNIEnv *env, jclass type, jobject member) {
if (member == NULL)
return;
art::mirror::ArtMethod* method = reinterpret_cast<art::mirror::ArtMethod *>(env->FromReflectedMethod(member));
if (method != nullptr && !method->isCompiled()) {
SandHook::StopTheWorld stopTheWorld;
method->compile(env);
}
}
extern "C" extern "C"
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_com_swift_sandhook_SandHook_setHookMode(JNIEnv *env, jclass type, jint mode) { Java_com_swift_sandhook_SandHook_setHookMode(JNIEnv *env, jclass type, jint mode) {
......
...@@ -176,7 +176,7 @@ public class SandHook { ...@@ -176,7 +176,7 @@ public class SandHook {
private static void resolveStaticMethod(Member method) { public static void resolveStaticMethod(Member method) {
//ignore result, just call to trigger resolve //ignore result, just call to trigger resolve
try { try {
if (method instanceof Method && Modifier.isStatic(method.getModifiers())) { if (method instanceof Method && Modifier.isStatic(method.getModifiers())) {
...@@ -288,6 +288,8 @@ public class SandHook { ...@@ -288,6 +288,8 @@ public class SandHook {
public static native void ensureMethodDeclaringClass(Member originMethod, Method backupMethod); public static native void ensureMethodDeclaringClass(Member originMethod, Method backupMethod);
public static native void compileMethod(Member member);
@FunctionalInterface @FunctionalInterface
public interface HookModeCallBack { public interface HookModeCallBack {
int hookMode(Member originMethod); int hookMode(Member originMethod);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment