in apache-rat-plugin/src/main/java/org/apache/rat/mp/util/ConfigurationHelper.java [31:59]
public static <T> T newInstance(final Class<T> clazz, final String className)
throws MojoExecutionException, MojoFailureException {
try {
final ClassLoader cl = Thread.currentThread()
.getContextClassLoader();
@SuppressWarnings("unchecked") // incorrect cast will be caught below
final T o = (T) cl.loadClass(className).newInstance();
if (!clazz.isAssignableFrom(o.getClass())) {
throw new MojoFailureException("The class "
+ o.getClass().getName() + " does not implement "
+ clazz.getName());
}
return o;
} catch (final InstantiationException e) {
throw new MojoExecutionException("Failed to instantiate class "
+ className + ": " + e.getMessage(), e);
} catch (final ClassCastException e) {
throw new MojoExecutionException("The class " + className
+ " is not implementing " + clazz.getName() + ": "
+ e.getMessage(), e);
} catch (final IllegalAccessException e) {
throw new MojoExecutionException("Illegal access to class "
+ className + ": " + e.getMessage(), e);
} catch (final ClassNotFoundException e) {
throw new MojoExecutionException("Class " + className
+ " not found: " + e.getMessage(), e);
}
}