Missing statements to record the underlying cause of InvocationTargetException might make the code harder to debug.
1public Object invokeMethodNonCompliant(Method method, Object[] args) throws Throwable {
2 // Noncompliant: InvocationTargetException is not caught.
3 return method.invoke(args);
4}
1public Object invokeMethodCompliant(Object proxy, Method method, Object[] args) throws Throwable {
2 try {
3 // Compliant: InvocationTargetException is caught and e.getCause() is propagated further.
4 Object returnValue = method.invoke(args);
5 return returnValue;
6 } catch (InvocationTargetException e) {
7 throw e.getTargetException();
8 }
9}