try {
return constructor.newInstance (args);
}
catch (InstantiationException ie) {
logger.error ("unexpected-instantiation-exception", ie);
throw new UndeclaredThrowableException (ie);
}
catch (IllegalAccessException iae) {
logger.error ("unexpected-illegal-access-exception", iae);
throw new UndeclaredThrowableException (iae);
}
catch (InvocationTargetException ite) {
Throwable t = ite.getTargetException ();
logger.error ("unexpected-invocation-target-exception", t);
if (t instanceof Error) {
throw (Error) t;
} else if (t instanceof RuntimeException) {
throw (RuntimeException) t;
} else {
throw new UndeclaredThrowableException (t);
}
}
catch (ExceptionInInitializerError eiie) {
Throwable t = eiie.getException ();
if (t == null) {
logger.error ("unexpected-exception", eiie);
throw new RuntimeException ("Internal error");
} else if (t instanceof Error) {
throw (Error) t;
} else if (t instanceof RuntimeException) {
throw (RuntimeException) t;
} else {
throw new UndeclaredThrowableException (t);
}
}
}