Commit fd058608 authored by swift_gan's avatar swift_gan Committed by swift_gan

fix resolve static method

parent 0f5ddd3b
...@@ -167,14 +167,25 @@ public class SandHook { ...@@ -167,14 +167,25 @@ public class SandHook {
return ensureMethodDeclaringClass(originMethod, hookEntity.backup); return ensureMethodDeclaringClass(originMethod, hookEntity.backup);
} }
private static void resolveStaticMethod(Member method) { private 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())) {
((Method) method).setAccessible(true); ((Method) method).setAccessible(true);
((Method) method).invoke(new Object()); ((Method) method).invoke(new Object(), getFakeArgs((Method) method));
} }
} catch (Exception e) { } catch (Throwable throwable) {
}
}
private static Object[] getFakeArgs(Method method) {
Class[] pars = method.getParameterTypes();
if (pars == null || pars.length == 0) {
return new Object[]{new Object()};
} else {
return null;
} }
} }
......
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