ClassLoader cl = (loader != null ? loader : ObjectUtils.class.getClassLoader());
Class<?> clz = null;
try {
clz = cl.loadClass(className);
} catch (ClassNotFoundException e) {
throw new EsHadoopIllegalStateException(String.format("Cannot load class [%s]", className), e);
}
try {
return (T) clz.newInstance();
} catch (Exception e) {
throw new EsHadoopIllegalStateException(String.format("Cannot instantiate class [%s]", className), e);
}
}