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;

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final List f2682a = hb.a.m0(Application.class, l0.class);

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final List f2683b = hb.a.l0(l0.class);

    public static final Constructor a(List list, Class cls) {
        nb.g.i(list, "signature");
        Constructor<?>[] constructors = cls.getConstructors();
        nb.g.h(constructors, "modelClass.constructors");
        for (Constructor<?> constructor : constructors) {
            Class<?>[] parameterTypes = constructor.getParameterTypes();
            nb.g.h(parameterTypes, "constructor.parameterTypes");
            List listC0 = kotlin.collections.q.c0(parameterTypes);
            if (nb.g.c(list, listC0)) {
                return constructor;
            }
            if (list.size() == listC0.size() && listC0.containsAll(list)) {
                throw new UnsupportedOperationException("Class " + cls.getSimpleName() + " must have parameters in the proper order: " + list);
            }
        }
        return null;
    }

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