content: package androidx.fragment.app;
  
  import androidx.collection.SimpleArrayMap;
  import androidx.fragment.app.Fragment;
  import java.lang.reflect.InvocationTargetException;
  
  public class FragmentFactory {
      private static final SimpleArrayMap<ClassLoader, SimpleArrayMap<String, Class<?>>> sClassCacheMap = new SimpleArrayMap<>();
  
      static boolean isFragmentClass(ClassLoader classLoader, String className) {
          try {
              return Fragment.class.isAssignableFrom(loadClass(classLoader, className));
          } catch (ClassNotFoundException e) {
              return false;
          }
      }
  
      private static Class<?> loadClass(ClassLoader classLoader, String className) throws ClassNotFoundException {
          SimpleArrayMap<ClassLoader, SimpleArrayMap<String, Class<?>>> simpleArrayMap = sClassCacheMap;
          SimpleArrayMap simpleArrayMap2 = simpleArrayMap.get(classLoader);
          if (simpleArrayMap2 == null) {
              simpleArrayMap2 = new SimpleArrayMap();
              simpleArrayMap.put(classLoader, simpleArrayMap2);
          }
          Class<?> cls = (Class) simpleArrayMap2.get(className);
          if (cls != null) {
              return cls;
          }
          Class<?> cls2 = Class.forName(className, false, classLoader);
          simpleArrayMap2.put(className, cls2);
          return cls2;
      }
  
      public static Class<? extends Fragment> loadFragmentClass(ClassLoader classLoader, String className) {
          try {
              return loadClass(classLoader, className);
          } catch (ClassNotFoundException e) {
              throw new Fragment.InstantiationException("Unable to instantiate fragment " + className + ": make sure class name exists", e);
          } catch (ClassCastException e2) {
              throw new Fragment.InstantiationException("Unable to instantiate fragment " + className + ": make sure class is a valid subclass of Fragment", e2);
          }
      }
  
      public Fragment instantiate(ClassLoader classLoader, String className) {
          try {
              return (Fragment) loadFragmentClass(classLoader, className).getConstructor(new Class[0]).newInstance(new Object[0]);
          } catch (InstantiationException e) {
              throw new Fragment.InstantiationException("Unable to instantiate fragment " + className + ": make sure class name exists, is public, and has an empty constructor that is public", e);
          } catch (IllegalAccessException e2) {
              throw new Fragment.InstantiationException("Unable to instantiate fragment " + className + ": make sure class name exists, is public, and has an empty constructor that is public", e2);
          } catch (NoSuchMethodException e3) {
              throw new Fragment.InstantiationException("Unable to instantiate fragment " + className + ": could not find Fragment constructor", e3);
          } catch (InvocationTargetException e4) {
              throw new Fragment.InstantiationException("Unable to instantiate fragment " + className + ": calling Fragment constructor caused an exception", e4);
          }
      }
  }
  