private static void invokeMethod(final Method method, final Object target, final Object[] parameters) {
try {
method.invoke(target, parameters);
} catch (final SecurityException e) {
throw new MetaModelException(String.format("Cannot access the %s method in %s", method.getName(), target.getClass().getName()));
} catch (final IllegalArgumentException e1) {
throw new MetaModelException(e1);
} catch (final IllegalAccessException e1) {
throw new MetaModelException(String.format("Cannot access the %s method in %s", method.getName(), target.getClass().getName()));
} catch (final InvocationTargetException e) {
final Throwable targetException = e.getTargetException();
if (targetException instanceof RuntimeException) {
throw (RuntimeException) targetException;
} else {
throw new MetaModelException(targetException);
}
}
}