UnsafeAllocator.java
2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package com.google.gson.internal;
import java.io.ObjectInputStream;
import java.io.ObjectStreamClass;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
public abstract class UnsafeAllocator
{
public static UnsafeAllocator create()
{
try
{
Object localObject1 = Class.forName("sun.misc.Unsafe");
final Object localObject4 = ((Class)localObject1).getDeclaredField("theUnsafe");
((Field)localObject4).setAccessible(true);
localObject4 = ((Field)localObject4).get(null);
localObject1 = new UnsafeAllocator()
{
public final <T> T newInstance(Class<T> paramAnonymousClass)
throws Exception
{
return (T)this.a.invoke(localObject4, new Object[] { paramAnonymousClass });
}
};
return (UnsafeAllocator)localObject1;
}
catch (Exception localException1)
{
try
{
Object localObject2 = ObjectStreamClass.class.getDeclaredMethod("getConstructorId", new Class[] { Class.class });
((Method)localObject2).setAccessible(true);
final int i = ((Integer)((Method)localObject2).invoke(null, new Object[] { Object.class })).intValue();
localObject2 = ObjectStreamClass.class.getDeclaredMethod("newInstance", new Class[] { Class.class, Integer.TYPE });
((Method)localObject2).setAccessible(true);
localObject2 = new UnsafeAllocator()
{
public final <T> T newInstance(Class<T> paramAnonymousClass)
throws Exception
{
return (T)this.a.invoke(null, new Object[] { paramAnonymousClass, Integer.valueOf(i) });
}
};
return (UnsafeAllocator)localObject2;
}
catch (Exception localException2)
{
try
{
Object localObject3 = ObjectInputStream.class.getDeclaredMethod("newInstance", new Class[] { Class.class, Class.class });
((Method)localObject3).setAccessible(true);
localObject3 = new UnsafeAllocator()
{
public final <T> T newInstance(Class<T> paramAnonymousClass)
throws Exception
{
return (T)this.a.invoke(null, new Object[] { paramAnonymousClass, Object.class });
}
};
return (UnsafeAllocator)localObject3;
}
catch (Exception localException3) {}
}
}
new UnsafeAllocator()
{
public final <T> T newInstance(Class<T> paramAnonymousClass)
{
throw new UnsupportedOperationException("Cannot allocate " + paramAnonymousClass);
}
};
}
public abstract <T> T newInstance(Class<T> paramClass)
throws Exception;
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/google/gson/internal/UnsafeAllocator.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/