Commit d0f5ffd7 authored by swift_gan's avatar swift_gan

fix dead loop when hook "getCallingClassLoader"

parent 17cfb2c4
...@@ -34,6 +34,8 @@ public final class Unsafe { ...@@ -34,6 +34,8 @@ public final class Unsafe {
private volatile static boolean supported = false; private volatile static boolean supported = false;
private static Class objectArrayClass = Object[].class;
static { static {
try { try {
unsafeClass = Class.forName("sun.misc.Unsafe"); unsafeClass = Class.forName("sun.misc.Unsafe");
...@@ -111,10 +113,10 @@ public final class Unsafe { ...@@ -111,10 +113,10 @@ public final class Unsafe {
public static long getObjectAddress(Object obj) { public static long getObjectAddress(Object obj) {
try { try {
Object[] array = new Object[]{obj}; Object[] array = new Object[]{obj};
if (arrayIndexScale(Object[].class) == 8) { if (arrayIndexScale(objectArrayClass) == 8) {
return getLong(array, arrayBaseOffset(Object[].class)); return getLong(array, arrayBaseOffset(objectArrayClass));
} else { } else {
return 0xffffffffL & getInt(array, arrayBaseOffset(Object[].class)); return 0xffffffffL & getInt(array, arrayBaseOffset(objectArrayClass));
} }
} catch (Exception e) { } catch (Exception e) {
Log.w(TAG, e); Log.w(TAG, e);
......
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