/** * Invokes the method on {@code target}. Throws an error if the method is not supported. Any * RuntimeException thrown by the method is thrown, checked exceptions are wrapped in an {@link * AssertionError}. * * @throws IllegalArgumentException if the arguments are invalid */ public Object invokeWithoutCheckedException(T target, Object... args) { try { return invoke(target, args); } catch (InvocationTargetException e) { Throwable targetException = e.getTargetException(); if (targetException instanceof RuntimeException) { throw (RuntimeException) targetException; } AssertionError error = new AssertionError("Unexpected exception"); error.initCause(targetException); throw error; } }
/** * Invokes the method on {@code target}. Throws an error if the method is not supported. Any * RuntimeException thrown by the method is thrown, checked exceptions are wrapped in an {@link * AssertionError}. * * @throws IllegalArgumentException if the arguments are invalid */ public Object invokeWithoutCheckedException(T target, Object... args) { try { return invoke(target, args); } catch (InvocationTargetException e) { Throwable targetException = e.getTargetException(); if (targetException instanceof RuntimeException) { throw (RuntimeException) targetException; } AssertionError error = new AssertionError("Unexpected exception"); error.initCause(targetException); throw error; } }