List of utility methods to do Reflection Method Invoke
Object | invokeJdbcMethod(Method method, Object target) Invoke the specified JDBC API Method against the supplied target object with no arguments. return invokeJdbcMethod(method, target, new Object[0]); |
Object | invokeJdbcMethod(Method method, Object target) Invoke the specified JDBC API Method against the supplied target object with no arguments. return invokeJdbcMethod(method, target, new Object[0]); |
Object | invokeMethod(Class clazz, Object classObject, String methodName, Class[] paramTypes, Object... args) invoke Method try { if (paramTypes == null) { paramTypes = new Class[args.length]; for (int i = 0; i < args.length; i++) { if (args[i] instanceof Integer) { paramTypes[i] = int.class; } else { paramTypes[i] = args[i].getClass(); ... |
Object | invokeMethod(Class clazz, Object obj, String methodName, Class[] parametersTypes, Object[] parameters) Invokes specified method using reflection and returns result. Method method = clazz.getDeclaredMethod(methodName, parametersTypes);
method.setAccessible(true);
return method.invoke(obj, parameters);
|
Object | invokeMethod(Class clazz, String methodName, Object[] args) invoke Method return invokeMethod(clazz, null, methodName, args);
|
Object | invokeMethod(Class targetClass, Object obj, String methodName, Object arg) invoke Method Object result = null; try { Class argClasses[] = null; if (arg != null) argClasses = new Class[] { arg.getClass() }; Method method = getMethod(targetClass, methodName, argClasses); result = method.invoke(obj, new Object[] { arg }); } catch (Exception e) { ... |
Object | invokeMethod(Class extends E> clazz, E instance, String[] names, Object... args) invoke Method try { Method method = getMethod(clazz, names); if (method != null) return method.invoke(instance, args); } catch (Exception ex) { ex.printStackTrace(); return null; ... |
Object | invokeMethod(Class> clazz, Object object, String methodName, Class>[] parameterTypes, Object[] parameters) invoke Method Method method = getDeclaredMethod(clazz, methodName, parameterTypes); if (method == null) { throw new RuntimeException("Method `" + methodName + "` not found in class `" + clazz.getName() + "`."); if (!method.isAccessible()) { method.setAccessible(true); try { ... |
void | invokeMethod(Class> clazz, String method, Class>[] args, Object object, Object[] objects) invoke Method try { Method m = clazz.getDeclaredMethod(method, args); m.setAccessible(true); m.invoke(object, objects); } catch (Exception ex) { |
Object | invokeMethod(Class> clz, String methodName, Object... params) Invoke a non-public static method by name from a class. Method method = getMethod(clz, methodName, params);
return invokeMethod(null, method, params);
|