List of utility methods to do Reflection Method Static Invoke
Object | invokeStaticMethod(Class> cls, String methodName, Object... args) invoke Static Method int arguments = args.length; Class<?>[] parameterTypes = new Class[arguments]; for (int i = 0; i < arguments; i++) { parameterTypes[i] = args[i].getClass(); Method method = cls.getMethod(methodName, parameterTypes); return method.invoke(null, args); |
T | invokeStaticMethod(Class> cls, String name) invoke Static Method return invokeStaticMethod(cls, name, null);
|
Method | invokeStaticMethod(Class> klass, String methodName) invoke Static Method if (klass == null) { throw new NoSuchMethodException(); Method method = klass.getMethod(methodName, null); method.setAccessible(true); return method; |
Object | invokeStaticMethod(Class> objectType, String name, Class> paramTypes[], Object args[]) invoke Static Method Method method = objectType.getMethod(name, paramTypes); if (!method.isAccessible()) { method.setAccessible(true); try { return method.invoke(null, args); } catch (InvocationTargetException e) { throw e.getTargetException(); ... |
Object | invokeStaticMethod(Class> pClass, String pMethod, Object pParam) Gets an object from any given static method, with the given parameter. return invokeStaticMethod(pClass, pMethod, new Object[] { pParam }); |
Object | invokeStaticMethod(final Class> cls, final String methodName) Invoke the named static method. if (cls != null) { try { final Method method = cls.getDeclaredMethod(methodName); if (!method.isAccessible()) { method.setAccessible(true); return method.invoke(null); } catch (final NoSuchMethodException e) { ... |
Object | invokeStaticMethod(final Class> cls, final String methodName, final boolean throwException) Invoke the named static method. if (cls != null) { try { final Method method = cls.getDeclaredMethod(methodName); try { method.setAccessible(true); } catch (final Exception e) { return method.invoke(null); ... |
T | invokeStaticMethod(final Class Call the specified static method on the given class, using the given arguments. Method method = clazz.getMethod(methodName, parameterTypes);
return clazz.cast(method.invoke(null, arglist));
|
Object | invokeStaticMethod(final Method method, final Object... args) Invoke the specified static Method with the supplied arguments. if (method == null) { throw new IllegalArgumentException("Method must not be null."); if (!Modifier.isStatic(method.getModifiers())) { throw new IllegalArgumentException("Method must be static."); method.setAccessible(true); return method.invoke(null, args); ... |
Object | invokeStaticMethod(String className, String method, Class[] paramTypes, Object[] paramValues) invoke a static method on a class. Class clz = Class.forName(className);
Method m = clz.getDeclaredMethod(method, paramTypes);
return m.invoke(null, paramValues);
|