List of utility methods to do Method Call
T | invokeVirtual(String methodName, Object onObj, Class[] declaredArgTypes, Object... withArgs) invoke Virtual Class clazz = onObj.getClass(); while (clazz != null) { final Method method = clazz.getDeclaredMethod(methodName, declaredArgTypes); if (method != null) { method.setAccessible(true); return (T) method.invoke(onObj, withArgs); clazz = clazz.getSuperclass(); ... |
R | invokeVirtual(T o, Method method, Object... pa) Invoke a virtual Method method . try { return (R) method.invoke(o, pa); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { throw new RuntimeException(); |
void | invokeVoid(MethodHandle mh) invoke Void mh.invokeExact(); |
void | invokeVoidNoArgMethod(Class> declaringClass, String methodName, Object instance) invoke Void No Arg Method Method method = declaringClass.getDeclaredMethod(methodName); method.setAccessible(true); method.invoke(instance); |
void | invokeVoidSafe(Object obj, String methodName, Class paramClass, Object param) invoke Void Safe try { Method method = obj.getClass().getMethod(methodName, paramClass); method.invoke(obj, param); } catch (SecurityException e) { } catch (NoSuchMethodException e) { } catch (IllegalArgumentException e) { } catch (IllegalAccessException e) { } catch (InvocationTargetException e) { ... |
Object | invokeWithoutDeclaredExceptions(Method method, Object target, Object... args) invoke Without Declared Exceptions try { return doInvoke(method, target, args); } catch (Throwable t) { throw uncheck(t); |
void | invokeWithoutInvocationException(Method m, Object obj, Object... args) Invokes the given void method on the given object with the given arguments. try { invoke(m, obj, args); } catch (InvocationTargetException e) { throw new RuntimeException(new RuntimeException(e.getTargetException().toString())); |