package o;

import android.app.Application;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.NoSuchElementException;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.p40, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public abstract class AbstractC2115p40 {
    public static final List a = AbstractC0008Ai.S(Application.class, C0972d40.class);
    public static final List b = Collections.singletonList(C0972d40.class);

    public static final Constructor a(Class cls, List list) throws SecurityException {
        Constructor<?>[] constructors = cls.getConstructors();
        int i = 0;
        while (true) {
            if (!(i < constructors.length)) {
                return null;
            }
            int i2 = i + 1;
            try {
                Constructor<?> constructor = constructors[i];
                List listV = AbstractC2219q9.V(constructor.getParameterTypes());
                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);
                }
                i = i2;
            } catch (ArrayIndexOutOfBoundsException e) {
                throw new NoSuchElementException(e.getMessage());
            }
        }
    }

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