package b5; 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: classes2.dex */ public abstract class m { class a extends m { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ Method f3216a; /* renamed from: b, reason: collision with root package name */ final /* synthetic */ Object f3217b; a(Method method, Object obj) { this.f3216a = method; this.f3217b = obj; } @Override // b5.m public Object c(Class cls) { m.a(cls); return this.f3216a.invoke(this.f3217b, cls); } } class b extends m { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ Method f3218a; /* renamed from: b, reason: collision with root package name */ final /* synthetic */ int f3219b; b(Method method, int i10) { this.f3218a = method; this.f3219b = i10; } @Override // b5.m public Object c(Class cls) { m.a(cls); return this.f3218a.invoke(null, cls, Integer.valueOf(this.f3219b)); } } class c extends m { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ Method f3220a; c(Method method) { this.f3220a = method; } @Override // b5.m public Object c(Class cls) { m.a(cls); return this.f3220a.invoke(null, cls, Object.class); } } class d extends m { d() { } @Override // b5.m public Object c(Class cls) { throw new UnsupportedOperationException("Cannot allocate " + cls); } } static void a(Class cls) { int modifiers = cls.getModifiers(); if (Modifier.isInterface(modifiers)) { throw new UnsupportedOperationException("Interface can't be instantiated! Interface name: " + cls.getName()); } if (Modifier.isAbstract(modifiers)) { throw new UnsupportedOperationException("Abstract class can't be instantiated! Class name: " + cls.getName()); } } public static m b() { try { Class cls = Class.forName("sun.misc.Unsafe"); Field declaredField = cls.getDeclaredField("theUnsafe"); declaredField.setAccessible(true); return new a(cls.getMethod("allocateInstance", Class.class), declaredField.get(null)); } 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 b(declaredMethod2, intValue); } catch (Exception unused2) { return new d(); } } catch (Exception unused3) { Method declaredMethod3 = ObjectInputStream.class.getDeclaredMethod("newInstance", Class.class, Class.class); declaredMethod3.setAccessible(true); return new c(declaredMethod3); } } } public abstract Object c(Class cls); }