package androidx.fragment.app;

import androidx.fragment.app.o;
import defpackage.vw2;
import defpackage.zs8;
import java.lang.reflect.InvocationTargetException;

/* JADX INFO: loaded from: classes.dex */
public class v {
    public static final zs8 a = new zs8(0);

    public static Class b(ClassLoader classLoader, String str) throws ClassNotFoundException {
        zs8 zs8Var = a;
        zs8 zs8Var2 = (zs8) zs8Var.get(classLoader);
        if (zs8Var2 == null) {
            zs8Var2 = new zs8(0);
            zs8Var.put(classLoader, zs8Var2);
        }
        Class cls = (Class) zs8Var2.get(str);
        if (cls != null) {
            return cls;
        }
        Class<?> cls2 = Class.forName(str, false, classLoader);
        zs8Var2.put(str, cls2);
        return cls2;
    }

    public static Class c(ClassLoader classLoader, String str) {
        try {
            return b(classLoader, str);
        } catch (ClassCastException e) {
            throw new o.j(vw2.ab("Unable to instantiate fragment ", str, ": make sure class is a valid subclass of Fragment"), e);
        } catch (ClassNotFoundException e2) {
            throw new o.j(vw2.ab("Unable to instantiate fragment ", str, ": make sure class name exists"), e2);
        }
    }

    public o a(ClassLoader classLoader, String str) {
        try {
            return (o) c(classLoader, str).getConstructor(null).newInstance(null);
        } catch (IllegalAccessException e) {
            throw new o.j(vw2.ab("Unable to instantiate fragment ", str, ": make sure class name exists, is public, and has an empty constructor that is public"), e);
        } catch (InstantiationException e2) {
            throw new o.j(vw2.ab("Unable to instantiate fragment ", str, ": make sure class name exists, is public, and has an empty constructor that is public"), e2);
        } catch (NoSuchMethodException e3) {
            throw new o.j(vw2.ab("Unable to instantiate fragment ", str, ": could not find Fragment constructor"), e3);
        } catch (InvocationTargetException e4) {
            throw new o.j(vw2.ab("Unable to instantiate fragment ", str, ": calling Fragment constructor caused an exception"), e4);
        }
    }
}
