package androidx.lifecycle;

import android.app.Application;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.List;
import n2.AbstractC2612c;
import x4.AbstractC3250p;
import x4.AbstractC3252r;

/* JADX INFO: loaded from: classes.dex */
public abstract class a0 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final List f12156a = AbstractC3252r.B(Application.class, U.class);

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final List f12157b = AbstractC2612c.q(U.class);

    public static final Constructor a(Class cls, List signature) {
        kotlin.jvm.internal.o.h(signature, "signature");
        F1.I iK = kotlin.jvm.internal.o.k(cls.getConstructors());
        while (iK.hasNext()) {
            Constructor constructor = (Constructor) iK.next();
            Class<?>[] parameterTypes = constructor.getParameterTypes();
            kotlin.jvm.internal.o.g(parameterTypes, "getParameterTypes(...)");
            List listX = AbstractC3250p.X(parameterTypes);
            if (signature.equals(listX)) {
                return constructor;
            }
            if (signature.size() == listX.size() && listX.containsAll(signature)) {
                throw new UnsupportedOperationException("Class " + cls.getSimpleName() + " must have parameters in the proper order: " + signature);
            }
        }
        return null;
    }

    public static final b0 b(Class cls, Constructor constructor, Object... objArr) {
        try {
            return (b0) constructor.newInstance(Arrays.copyOf(objArr, objArr.length));
        } catch (IllegalAccessException e6) {
            throw new RuntimeException("Failed to access " + cls, e6);
        } catch (InstantiationException e7) {
            throw new RuntimeException("A " + cls + " cannot be instantiated.", e7);
        } catch (InvocationTargetException e8) {
            throw new RuntimeException("An exception happened in constructor of " + cls, e8.getCause());
        }
    }
}
