public static <T> T createInstanceOfType(String className) {
try {
Class type = Class.forName(className);
return (T) newInstance(type);
} catch (ClassCastException e) {
throw new JTesterException("Class " + className + " is not of expected type.", e);
} catch (NoClassDefFoundError e) {
throw new JTesterException("Unable to load class " + className, e);
} catch (ClassNotFoundException e) {
throw new JTesterException("Class " + className + " not found", e);
} catch (JTesterException e) {
throw e;
} catch (Throwable e) {
throw new JTesterException("Error while instantiating class " + className, e);
}
}