98 lines
4.0 KiB
Java
98 lines
4.0 KiB
Java
package com.facetec.sdk;
|
|
|
|
import java.io.ObjectInputStream;
|
|
import java.io.ObjectStreamClass;
|
|
import java.lang.reflect.Field;
|
|
import java.lang.reflect.Method;
|
|
import java.lang.reflect.Modifier;
|
|
|
|
/* loaded from: classes.dex */
|
|
public abstract class fb {
|
|
public abstract <T> T b(Class<T> cls) throws Exception;
|
|
|
|
public static fb a() {
|
|
try {
|
|
Class<?> cls = Class.forName("sun.misc.Unsafe");
|
|
Field declaredField = cls.getDeclaredField("theUnsafe");
|
|
declaredField.setAccessible(true);
|
|
return new fb(cls.getMethod("allocateInstance", Class.class), declaredField.get(null)) { // from class: com.facetec.sdk.fb.5
|
|
private Method a;
|
|
private Object c;
|
|
|
|
{
|
|
this.a = r1;
|
|
this.c = r2;
|
|
}
|
|
|
|
@Override // com.facetec.sdk.fb
|
|
public final <T> T b(Class<T> cls2) throws Exception {
|
|
d(cls2);
|
|
return (T) this.a.invoke(this.c, cls2);
|
|
}
|
|
};
|
|
} catch (Exception unused) {
|
|
try {
|
|
try {
|
|
Method declaredMethod = ObjectStreamClass.class.getDeclaredMethod("getConstructorId", Class.class);
|
|
declaredMethod.setAccessible(true);
|
|
int intValue = ((Integer) declaredMethod.invoke(null, Object.class)).intValue();
|
|
Method declaredMethod2 = ObjectStreamClass.class.getDeclaredMethod("newInstance", Class.class, Integer.TYPE);
|
|
declaredMethod2.setAccessible(true);
|
|
return new fb(declaredMethod2, intValue) { // from class: com.facetec.sdk.fb.1
|
|
private Method a;
|
|
private int b;
|
|
|
|
{
|
|
this.a = declaredMethod2;
|
|
this.b = intValue;
|
|
}
|
|
|
|
@Override // com.facetec.sdk.fb
|
|
public final <T> T b(Class<T> cls2) throws Exception {
|
|
d(cls2);
|
|
return (T) this.a.invoke(null, cls2, Integer.valueOf(this.b));
|
|
}
|
|
};
|
|
} catch (Exception unused2) {
|
|
return new fb() { // from class: com.facetec.sdk.fb.2
|
|
@Override // com.facetec.sdk.fb
|
|
public final <T> T b(Class<T> cls2) {
|
|
throw new UnsupportedOperationException("Cannot allocate ".concat(String.valueOf(cls2)));
|
|
}
|
|
};
|
|
}
|
|
} catch (Exception unused3) {
|
|
Method declaredMethod3 = ObjectInputStream.class.getDeclaredMethod("newInstance", Class.class, Class.class);
|
|
declaredMethod3.setAccessible(true);
|
|
return new fb(declaredMethod3) { // from class: com.facetec.sdk.fb.4
|
|
private Method d;
|
|
|
|
{
|
|
this.d = declaredMethod3;
|
|
}
|
|
|
|
@Override // com.facetec.sdk.fb
|
|
public final <T> T b(Class<T> cls2) throws Exception {
|
|
d(cls2);
|
|
return (T) this.d.invoke(null, cls2, Object.class);
|
|
}
|
|
};
|
|
}
|
|
}
|
|
}
|
|
|
|
static void d(Class<?> cls) {
|
|
int modifiers = cls.getModifiers();
|
|
if (Modifier.isInterface(modifiers)) {
|
|
StringBuilder sb = new StringBuilder("Interface can't be instantiated! Interface name: ");
|
|
sb.append(cls.getName());
|
|
throw new UnsupportedOperationException(sb.toString());
|
|
}
|
|
if (Modifier.isAbstract(modifiers)) {
|
|
StringBuilder sb2 = new StringBuilder("Abstract class can't be instantiated! Class name: ");
|
|
sb2.append(cls.getName());
|
|
throw new UnsupportedOperationException(sb2.toString());
|
|
}
|
|
}
|
|
}
|