try {
makeAccessible(ctor);
return ctor.newInstance(args);
} catch (InstantiationException ex) {
throw new ReflectionException("Error during instanciation of '"
+ ctor.getDeclaringClass().getName() + "'. Is it an abstract class?", ex);
} catch (IllegalAccessException ex) {
throw new ReflectionException("Error during instanciation of '"
+ ctor.getDeclaringClass().getName()
+ "'. Has the class definition changed? Is the constructor accessible?", ex);
} catch (IllegalArgumentException ex) {
throw new ReflectionException("Error during instanciation of '"
+ ctor.getDeclaringClass().getName() + "'. Illegal arguments for constructor", ex);
} catch (InvocationTargetException ex) {
if (GwtTestException.class.isInstance(ex.getTargetException())) {
throw (GwtTestException) ex.getTargetException();
} else if (GwtTestException.class.isInstance(ex.getTargetException().getCause())) {
throw (GwtTestException) ex.getTargetException().getCause();
} else {
throw new ReflectionException("Error during instanciation of '"
+ ctor.getDeclaringClass().getName() + "'. Constructor threw exception",
ex.getTargetException());
}
}