/** * Convert an Exception to RuntimeException * @param e the Exception instance * @return a RuntimeException instance */ public static RuntimeException asRuntimeException(Exception e) { if (e instanceof RuntimeException) { return (RuntimeException) e; } return UnexpectedMethodInvocationException.triage(e); }
/** * Convert an Exception to RuntimeException * @param e the Exception instance * @return a RuntimeException instance */ public static RuntimeException asRuntimeException(Exception e) { if (e instanceof RuntimeException) { return (RuntimeException) e; } return UnexpectedMethodInvocationException.triage(e); }
/** * Invoke a static method. This method will convert all checked exception * into corresponding runtime exception * * @param method * the method * @param pa * the arguments to invoke the method * @param <R> * the generic type of the return result * @return the result of the method invocation */ public static <R> R invokeStatic(Method method, Object... pa) { try { return (R) method.invoke(null, pa); } catch (Exception e) { throw UnexpectedMethodInvocationException.triage(e); } }
/** * Invoke a static method. This method will convert all checked exception * into corresponding runtime exception * * @param method * the method * @param pa * the arguments to invoke the method * @param <R> * the generic type of the return result * @return the result of the method invocation */ public static <R> R invokeStatic(Method method, Object... pa) { try { return (R) method.invoke(null, pa); } catch (Exception e) { throw UnexpectedMethodInvocationException.triage(e); } }
/** * Invoke a virtual {@link Method method}. This method will convert all checked exception * to corresponding runtime exception * * @param o * the instance on which the method will be invoked * @param method * the method * @param pa * the arguments * @param <T> * generic type of the instance * @param <R> * generic type of the result * @return result of method invocation */ public static <T, R> R invokeVirtual(T o, Method method, Object... pa) { E.NPE(o); try { return (R) method.invoke(o, pa); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw UnexpectedMethodInvocationException.triage(e); } }
/** * Invoke a virtual {@link Method method}. This method will convert all checked exception * to corresponding runtime exception * * @param o * the instance on which the method will be invoked * @param method * the method * @param pa * the arguments * @param <T> * generic type of the instance * @param <R> * generic type of the result * @return result of method invocation */ public static <T, R> R invokeVirtual(T o, Method method, Object... pa) { E.NPE(o); try { return (R) method.invoke(o, pa); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw UnexpectedMethodInvocationException.triage(e); } }
throw e; } catch (Exception e) { throw UnexpectedMethodInvocationException.triage(e);
throw e; } catch (Exception e) { throw UnexpectedMethodInvocationException.triage(e);