Here you can find the source of invokeWithoutDeclaredExceptions(Method method, Object target, Object... args)
public static Object invokeWithoutDeclaredExceptions(Method method, Object target, Object... args)
//package com.java2s; //License from project: Apache License import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.UndeclaredThrowableException; public class Main { public static Object invokeWithoutDeclaredExceptions(Method method, Object target, Object... args) { try {/*from w w w . j a v a2 s.c o m*/ return doInvoke(method, target, args); } catch (Throwable t) { throw uncheck(t); } } private static Object doInvoke(Method method, Object target, Object... args) throws Throwable { try { return method.invoke(target, args); } catch (InvocationTargetException e) { throw e.getCause(); } } private static RuntimeException uncheck(Throwable t) { if (t instanceof RuntimeException) { throw (RuntimeException) t; } if (t instanceof Error) { throw (Error) t; } throw new UndeclaredThrowableException(t); } }