framework/oryx-common/src/main/java/com/cloudera/oryx/common/lang/ClassUtils.java
public static <T> T loadInstanceOf(String implClassName,
                                     Class<T> superClass,
                                     Class<?>[] constructorTypes,
                                     Object[] constructorArgs) {
    try {
      Class<? extends T> configClass = loadClass(implClassName, superClass);
      Constructor<? extends T> constructor = configClass.getConstructor(constructorTypes);
      return constructor.newInstance(constructorArgs);
    } catch (NoSuchMethodException | InstantiationException | IllegalAccessException e) {
      throw new IllegalArgumentException("No valid " + superClass + " binding exists", e);
    } catch (InvocationTargetException ite) {
      throw new IllegalStateException("Could not instantiate " + superClass + " due to exception",
                                      ite.getCause());
    }
  }
public static <T> T loadInstanceOf(String implClassName,
                                     Class<T> superClass,
                                     Class<?>[] constructorTypes,
                                     Object[] constructorArgs) {
    try {
      Class<? extends T> configClass = loadClass(implClassName, superClass);
      Constructor<? extends T> constructor = configClass.getConstructor(constructorTypes);
      return constructor.newInstance(constructorArgs);
    } catch (NoSuchMethodException | InstantiationException | IllegalAccessException e) {
      throw new IllegalArgumentException("No valid " + superClass + " binding exists", e);
    } catch (InvocationTargetException ite) {
      throw new IllegalStateException("Could not instantiate " + superClass + " due to exception",
                                      ite.getCause());
    }
  }
Loads and instantiates a named implementation class, a subclass of a given supertype,
whose constructor takes the given arguments.

@param implClassName implementation class name
@param superClass superclass or interface that the implementation extends
@param constructorTypes argument types of constructor to use
@param constructorArgs actual constructor arguments
@param <T> type of returned instance
@return instance of {@code implClassName}