Class<?> instrumentorClass = classLoader.loadClass(s);
if (expectedClass.isAssignableFrom(instrumentorClass)) {
Class<? extends T> ic2 = instrumentorClass.asSubclass(expectedClass);
return ic2.newInstance();
} else {
throw new BuilderException("Class " + s + " does not implement the " +
expectedClass.getName() + " interface");
}
}
catch (InstantiationException e) {
throw new BuilderException("Could not instanciate " + option.getShortName() + " " + s, e);
}
catch (IllegalAccessException e) {
throw new BuilderException("Could not instanciate " + option.getShortName(), e);
}
catch (ClassNotFoundException e) {
throw new BuilderException("Could not load " + option.getShortName() + " class " + s, e);
}
}