package androidx.lifecycle;

import android.app.Application;
import e4.AbstractC0564h;
import e4.AbstractC0566j;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.List;
import r4.AbstractC0983h;

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final List f4452a = AbstractC0566j.s(Application.class, O.class);

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final List f4453b = AbstractC0566j.r(O.class);

    public static final Constructor a(Class cls, List list) {
        AbstractC0983h.e("signature", list);
        Constructor<?>[] constructors = cls.getConstructors();
        AbstractC0983h.d("modelClass.constructors", constructors);
        for (Constructor<?> constructor : constructors) {
            Class<?>[] parameterTypes = constructor.getParameterTypes();
            AbstractC0983h.d("constructor.parameterTypes", parameterTypes);
            List listV = AbstractC0564h.V(parameterTypes);
            if (list.equals(listV)) {
                return constructor;
            }
            if (list.size() == listV.size() && listV.containsAll(list)) {
                throw new UnsupportedOperationException("Class " + cls.getSimpleName() + " must have parameters in the proper order: " + list);
            }
        }
        return null;
    }

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