List of utility methods to do Method Call
void | invokeProxied(final Callable> callable, final ClassLoader classLoader) Runs a Callable within a Proxy instance. Callable<?> callableProxy = (Callable) Proxy.newProxyInstance(classLoader, new Class<?>[] { Callable.class }, new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { callable.call(); return null; }); ... |
void | invokePublicMethod(Object o, String methodName, Class[] classes, Object[] objects) invoke Public Method try { Method m = o.getClass().getMethod(methodName, classes); m.setAccessible(true); m.invoke(o, objects); } catch (Exception e) { e.printStackTrace(); |
void | invokeQuietly(MethodHandle handle, Object instance) invoke Quietly try { handle.invoke(instance); } catch (Throwable e) { e.printStackTrace(); |
Object | invokeQuietly(Object target, Method method, Object[] params) invoke Quietly Object result = null; try { result = method.invoke(target, params); } catch (InvocationTargetException invocationException) { for (Class<?> exceptionClass : method.getExceptionTypes()) { if (exceptionClass.isInstance(invocationException.getCause())) { throw invocationException.getCause(); throw new IllegalStateException(invocationException.getCause()); return result; |
Object | invokeReadResolveOn(Object object, Class> clz) If special method readResolve is available in this clz class, invoke it. try { Method readResolved = clz.getDeclaredMethod("readResolve"); if (readResolved != null) { readResolved.setAccessible(true); return readResolved.invoke(object); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { return null; |
Object | invokeReal(Object real, Method m, Object[] args) invoke Real try { return m.invoke(real, args); } catch (InvocationTargetException e) { throw e.getTargetException(); } catch (IllegalAccessException | IllegalArgumentException e) { throw new RuntimeException("unexpected invocation exception: " + e.getMessage()); |
R | invokeRemoteMBeanOperation(String remoteURL, String jmxName, Class invoke Remote M Bean Operation JMXServiceURL jmxURL = new JMXServiceURL(remoteURL); try (JMXConnector jmxc = JMXConnectorFactory.connect(jmxURL, null)) { MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); T remoteMBean = getMBean(jmxName, klass, mbsc); return function.apply(remoteMBean); |
Object | invokeRestrictedMethod(Object obj, Class theClass, String methodName) Call a private method without arguments. return invokeRestrictedMethod(obj, theClass, methodName, (Object) null);
|
Object | invokeServiceClass(JsonReader jsonReader, Object service, Method operation, Class[] paramClasses, int paramCount) invoke Service Class Object[] methodParam = new Object[paramCount]; Gson gson = new Gson(); String[] argNames = new String[paramCount]; if (!jsonReader.isLenient()) { jsonReader.setLenient(true); jsonReader.beginObject(); jsonReader.nextName(); ... |
void | invokeSet(Object o, String fieldName, Object value) invoke Set Method method = getSetMethod(o.getClass(), fieldName); try { method.invoke(o, new Object[] { value }); } catch (Exception e) { e.printStackTrace(); |