@Test public void shouldWrapAnyExceptionComingFromFunctionInJavaFunctionInvocationException() throws NoSuchMethodException { JavaMethodInvoker invoker = new JavaMethodInvoker(); FunctionWrapper wrapper = new FunctionWrapper(); catchException(invoker).invokeMethod(wrapper, FunctionWrapper.class.getDeclaredMethod("throwingMethod"), true); assertThat(caughtException()).isInstanceOf(JavaFunctionInvocationException.class); }
public Object invokeMethod(Object instance, Method method, boolean makeAccessible, Object... args) { try { if (makeAccessible) { method.setAccessible(true); } if (instance instanceof Proxy) { InvocationHandler handler = Proxy.getInvocationHandler(instance); return handler.invoke(instance, method, args); } else { return method.invoke(instance, args); } } catch (Throwable exception) { logger.error("", exception); throw new JavaFunctionInvocationException(exception, instance, method); } }
JavaMethodInvoker { public Object invokeMethod(Object instance, Method method, boolean makeAccessible, Object... args) { try { if (makeAccessible) { method.setAccessible(true); } if (instance instanceof Proxy) { InvocationHandler handler = Proxy.getInvocationHandler(instance); return handler.invoke(instance, method, args); } else { return method.invoke(instance, args); } } catch (Throwable exception) { logger.error("", exception); throw new JavaFunctionInvocationException(exception, instance, method); } } }
JavaMethodInvoker { public Object invokeMethod(Object instance, Method method, boolean makeAccessible, Object... args) { try { if (makeAccessible) { method.setAccessible(true); } if (instance instanceof Proxy) { InvocationHandler handler = Proxy.getInvocationHandler(instance); return handler.invoke(instance, method, args); } else { return method.invoke(instance, args); } } catch (Throwable exception) { logger.error("", exception); throw new JavaFunctionInvocationException(exception, instance, method); } }  }
JavaMethodInvoker { public Object invokeMethod(Object instance, Method method, boolean makeAccessible, Object... args) { try { if (makeAccessible) { method.setAccessible(true); } if (instance instanceof Proxy) { InvocationHandler handler = Proxy.getInvocationHandler(instance); return handler.invoke(instance, method, args); } else { return method.invoke(instance, args); } } catch (Throwable exception) { logger.error("", exception); throw new JavaFunctionInvocationException(exception, instance, method); } }  Object invokeMethod(Object instance, Method method, boolean makeAccessible, Object... args); }
JavaMethodInvoker { public Object invokeMethod(Object instance, Method method, boolean makeAccessible, Object... args) { try { if (makeAccessible) { method.setAccessible(true); } if (instance instanceof Proxy) { InvocationHandler handler = Proxy.getInvocationHandler(instance); return handler.invoke(instance, method, args); } else { return method.invoke(instance, args); } } catch (Throwable exception) { logger.error("", exception); throw new JavaFunctionInvocationException(exception, instance, method); } }  Object invokeMethod(Object instance, Method method, boolean makeAccessible, Object... args);  }