private Object doInvoke(MethodInvoker invoker) throws Exception{ try { invoker.prepare(); } catch (ClassNotFoundException e) { throw new DynamicMethodInvocationException(e); } catch (NoSuchMethodException e) { throw new DynamicMethodInvocationException(e); } try { return invoker.invoke(); } catch (InvocationTargetException e) { if (e.getCause() instanceof Exception) { throw (Exception) e.getCause(); } else { throw new InvocationTargetThrowableWrapper(e.getCause()); } } catch (IllegalAccessException e) { throw new DynamicMethodInvocationException(e); } }
@Test public void testInvalidMethodName() throws Exception { reader.setMethodName("thisMethodDoesNotExist"); try { reader.doPageRead(); fail(); } catch (DynamicMethodInvocationException dmie) { assertTrue(dmie.getCause() instanceof NoSuchMethodException); } }
private Object doInvoke(MethodInvoker invoker) throws Exception{ try { invoker.prepare(); } catch (ClassNotFoundException | NoSuchMethodException e) { throw new DynamicMethodInvocationException(e); } try { return invoker.invoke(); } catch (InvocationTargetException e) { if (e.getCause() instanceof Exception) { throw (Exception) e.getCause(); } else { throw new InvocationTargetThrowableWrapper(e.getCause()); } } catch (IllegalAccessException e) { throw new DynamicMethodInvocationException(e); } }
/** * Prepare and invoke the invoker, rethrow checked exceptions as unchecked. * @param invoker configured invoker * @return return value of the invoked method */ @SuppressWarnings("unchecked") private T doInvoke(MethodInvoker invoker) throws Exception { try { invoker.prepare(); } catch (ClassNotFoundException | NoSuchMethodException e) { throw new DynamicMethodInvocationException(e); } try { return (T) invoker.invoke(); } catch (InvocationTargetException e) { if (e.getCause() instanceof Exception) { throw (Exception) e.getCause(); } else { throw new InvocationTargetThrowableWrapper(e.getCause()); } } catch (IllegalAccessException e) { throw new DynamicMethodInvocationException(e); } }
private Object doInvoke(MethodInvoker invoker) throws Exception{ try { invoker.prepare(); } catch (ClassNotFoundException e) { throw new DynamicMethodInvocationException(e); } catch (NoSuchMethodException e) { throw new DynamicMethodInvocationException(e); } try { return invoker.invoke(); } catch (InvocationTargetException e) { if (e.getCause() instanceof Exception) { throw (Exception) e.getCause(); } else { throw new InvocationTargetThrowableWrapper(e.getCause()); } } catch (IllegalAccessException e) { throw new DynamicMethodInvocationException(e); } }
private Object doInvoke(MethodInvoker invoker) throws Exception{ try { invoker.prepare(); } catch (ClassNotFoundException | NoSuchMethodException e) { throw new DynamicMethodInvocationException(e); } try { return invoker.invoke(); } catch (InvocationTargetException e) { if (e.getCause() instanceof Exception) { throw (Exception) e.getCause(); } else { throw new InvocationTargetThrowableWrapper(e.getCause()); } } catch (IllegalAccessException e) { throw new DynamicMethodInvocationException(e); } }
/** * Prepare and invoke the invoker, rethrow checked exceptions as unchecked. * @param invoker configured invoker * @return return value of the invoked method */ @SuppressWarnings("unchecked") private T doInvoke(MethodInvoker invoker) throws Exception { try { invoker.prepare(); } catch (ClassNotFoundException | NoSuchMethodException e) { throw new DynamicMethodInvocationException(e); } try { return (T) invoker.invoke(); } catch (InvocationTargetException e) { if (e.getCause() instanceof Exception) { throw (Exception) e.getCause(); } else { throw new InvocationTargetThrowableWrapper(e.getCause()); } } catch (IllegalAccessException e) { throw new DynamicMethodInvocationException(e); } }