code: public static void rethrowRuntimeException(Throwable ex) {
          if (ex instanceof RuntimeException) {
              throw (RuntimeException) ex;
          }
          if (ex instanceof Error) {
              throw (Error) ex;
          }
          throw new UndeclaredThrowableException(ex);
      }
docs: Rethrow the given {@link Throwable exception}, which is presumably the <em>target exception</em> of an
  {@link InvocationTargetException}. Should only be called if no checked exception is expected to be thrown by the target
  method.
  <p>
  Rethrows the underlying exception cast to a {@link RuntimeException} or {@link Error} if appropriate; otherwise, throws
  an {@link UndeclaredThrowableException}.
  
  @param ex the exception to rethrow
  @throws RuntimeException the rethrown exception