code: public static <T> T createInstance(Class<?> rawClass, Class<T> superclass) {
      try {
        return rawClass.asSubclass(superclass).getConstructor().newInstance();
      } catch (Exception e) {
        throw new ServiceConfigurationError(
            "Provider " + rawClass.getName() + " could not be instantiated.", e);
      }
    }
docs: Tries to create an instance of the given rawClass as a subclass of the given superclass.
  
  @param rawClass The class that is initialized.
  @param superclass The initialized class must be a subclass of this.
  @return an instance of the class given rawClass which is a subclass of the given superclass.
  @throws ServiceConfigurationError if any error happens.