try {
final T instance;
if (_hasClosureArgument) {
final Constructor<?> constructor = generatedClass.getConstructor(Closure.class);
final Closure closure = new Closure(_boundConstants.toArray(), null);
instance = (T) constructor.newInstance(closure);
}
else {
instance = generatedClass.newInstance();
}