List of usage examples for org.apache.commons.lang3.reflect MethodUtils invokeStaticMethod
public static Object invokeStaticMethod(final Class<?> cls, final String methodName, Object[] args, Class<?>[] parameterTypes) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
Invokes a named static method whose parameter type matches the object type.
This method delegates the method search to #getMatchingAccessibleMethod(Class,String,Class[]) .
This method supports calls to methods taking primitive parameters via passing in wrapping classes.
From source file:com.feilong.core.lang.reflect.MethodUtil.java
/** * ??./*from ww w. ja va 2 s . co m*/ * * @param <T> * the generic type * @param klass * the klass * @param methodName * the method name * @param args * the args * @param parameterTypes * the parameter types * @return <code>klass</code> null, {@link NullPointerException}<br> * <code>methodName</code> null, {@link NullPointerException}<br> * <code>methodName</code> blank, {@link IllegalArgumentException}<br> * @see org.apache.commons.lang3.reflect.MethodUtils#invokeStaticMethod(Class, String, Object[], Class[]) * @since 1.1.1 */ @SuppressWarnings("unchecked") public static <T> T invokeStaticMethod(final Class<?> klass, final String methodName, Object[] args, Class<?>[] parameterTypes) { Validate.notNull(klass, "klass can't be null!"); Validate.notBlank(methodName, "methodName can't be blank!"); try { return (T) MethodUtils.invokeStaticMethod(klass, methodName, args, parameterTypes); } catch (Exception e) { String pattern = "invoke Static Method Exception,class:[{}],methodName:[{}],args:[{}],parameterTypes:[{}]"; throw new ReflectException(Slf4jUtil.format(pattern, klass.getName(), methodName, args, parameterTypes), e); } }