@Test public void shouldInvokeStaticMethod() { Object o = ReflectionUtils.invokeStaticMethod( ReflectionUtilsTest.class, "callable", new Class<?>[0], new Object[0] ); assertThat( o ) .isEqualTo( 3L ); }
public static Object invokeStaticMethod( Class<?> clazz, String methodName, Class<?>[] parameterTypes, Object[] parameters ) { if ( parameterTypes.length != parameters.length ) { throw new IllegalArgumentException( "arguments length do not match" ); } Method method = getMethod( clazz, methodName, parameterTypes ); return invokeMethodWithArray( null, method, parameters ); }
ReflectionUtils { public static Object invokeStaticMethod( Class<?> clazz, String methodName, Class<?>[] parameterTypes, Object[] parameters ) { if ( parameterTypes.length != parameters.length ) { throw new IllegalArgumentException( "arguments length do not match" ); } Method method = getMethod( clazz, methodName, parameterTypes ); return invokeMethodWithArray( null, method, parameters ); } }
ReflectionUtils { public static Object invokeStaticMethod( Class<?> clazz, String methodName, Class<?>[] parameterTypes, Object[] parameters ) { if ( parameterTypes.length != parameters.length ) { throw new IllegalArgumentException( "arguments length do not match" ); } Method method = getMethod( clazz, methodName, parameterTypes ); return invokeMethodWithArray( null, method, parameters ); } private  ReflectionUtils(); }
ReflectionUtils { public static Object invokeStaticMethod( Class<?> clazz, String methodName, Class<?>[] parameterTypes, Object[] parameters ) { if ( parameterTypes.length != parameters.length ) { throw new IllegalArgumentException( "arguments length do not match" ); } Method method = getMethod( clazz, methodName, parameterTypes ); return invokeMethodWithArray( null, method, parameters ); } private  ReflectionUtils(); static Method getMethod( Object instance, String methodName, Class<?>... parameters ); static Method getMethod( Class<?> clazz, String methodName, Class<?>... parameters ); static Method tryGetMethod( Class<?> clazz, String methodName, Class<?>... parameters ); static Object invokeGetter( Object instance, String methodName ); static Object invokeGetter( Class<?> instanceType, Object instance, String methodName ); static Constructor<?> getConstructor( Class<?> clazz, Class<?>... arguments ); static Object newInstance( Constructor<?> constructor, Object... params ); static T instantiate( ClassLoader classLoader, String classname, Class<T> returnType ); static Object instantiateOneArg( ClassLoader classLoader, String className, Class<?> param1Class,
                                            Object param1 ); static void invokeSetter( Object o, String name, Class<?> value1clazz, Object value ); static Object invokeSetter( Object target, Method method, Object value ); static Object invokeMethodWithArray( Object target, Method method, Object... args ); static Object invokeMethodWithArray2( Object target, Method method, Object... args ); static Object instantiateObject( String className, Class<?>[] types, Object[] params, ClassLoader cl ); @SuppressWarnings( "checkstyle:emptyblock" ) static Class<?> tryLoadClass( ClassLoader classLoader, String className ); static Class<?> loadClass( ClassLoader classLoader, String className ); static Class<?> reloadClass( ClassLoader classLoader, Object source ); static Object invokeStaticMethod( Class<?> clazz, String methodName,
                                             Class<?>[] parameterTypes, Object[] parameters ); static Object invokeMethodChain( Class<?>[] classesChain, String[] noArgMethodNames, Object fallback ); }
ReflectionUtils { public static Object invokeStaticMethod( Class<?> clazz, String methodName, Class<?>[] parameterTypes, Object[] parameters ) { if ( parameterTypes.length != parameters.length ) { throw new IllegalArgumentException( "arguments length do not match" ); } Method method = getMethod( clazz, methodName, parameterTypes ); return invokeMethodWithArray( null, method, parameters ); } private  ReflectionUtils(); static Method getMethod( Object instance, String methodName, Class<?>... parameters ); static Method getMethod( Class<?> clazz, String methodName, Class<?>... parameters ); static Method tryGetMethod( Class<?> clazz, String methodName, Class<?>... parameters ); static Object invokeGetter( Object instance, String methodName ); static Object invokeGetter( Class<?> instanceType, Object instance, String methodName ); static Constructor<?> getConstructor( Class<?> clazz, Class<?>... arguments ); static Object newInstance( Constructor<?> constructor, Object... params ); static T instantiate( ClassLoader classLoader, String classname, Class<T> returnType ); static Object instantiateOneArg( ClassLoader classLoader, String className, Class<?> param1Class,
                                            Object param1 ); static void invokeSetter( Object o, String name, Class<?> value1clazz, Object value ); static Object invokeSetter( Object target, Method method, Object value ); static Object invokeMethodWithArray( Object target, Method method, Object... args ); static Object invokeMethodWithArray2( Object target, Method method, Object... args ); static Object instantiateObject( String className, Class<?>[] types, Object[] params, ClassLoader cl ); @SuppressWarnings( "checkstyle:emptyblock" ) static Class<?> tryLoadClass( ClassLoader classLoader, String className ); static Class<?> loadClass( ClassLoader classLoader, String className ); static Class<?> reloadClass( ClassLoader classLoader, Object source ); static Object invokeStaticMethod( Class<?> clazz, String methodName,
                                             Class<?>[] parameterTypes, Object[] parameters ); static Object invokeMethodChain( Class<?>[] classesChain, String[] noArgMethodNames, Object fallback );  }