@Test public void invokeStatic() { Assert.assertEquals("value", ReflectUtils.invokeStatic("net.yui.utils.MockHelper", "testStatic")); Assert.assertEquals("arg0", ReflectUtils.invokeStatic("net.yui.utils.MockHelper", "testStatic", "arg0")); MockHelper mockHelper = new MockHelper(); Assert.assertEquals("value", ReflectUtils.invoke(mockHelper, "testMethod")); Assert.assertEquals("arg0", ReflectUtils.invoke(mockHelper, "testMethod", "arg0")); }
public static Object invokeStatic(String className, String methodName, Object... arguments) { try { Class clazz = Class.forName(className); return invokeStatic(clazz, methodName, arguments); } catch (ClassNotFoundException e) { e.printStackTrace(); } return null; }
ReflectUtils { public static Object invokeStatic(String className, String methodName, Object... arguments) { try { Class clazz = Class.forName(className); return invokeStatic(clazz, methodName, arguments); } catch (ClassNotFoundException e) { e.printStackTrace(); } return null; } }
ReflectUtils { public static Object invokeStatic(String className, String methodName, Object... arguments) { try { Class clazz = Class.forName(className); return invokeStatic(clazz, methodName, arguments); } catch (ClassNotFoundException e) { e.printStackTrace(); } return null; }  }
ReflectUtils { public static Object invokeStatic(String className, String methodName, Object... arguments) { try { Class clazz = Class.forName(className); return invokeStatic(clazz, methodName, arguments); } catch (ClassNotFoundException e) { e.printStackTrace(); } return null; }  static boolean hasClass(String className); static void setField(Object receiver, String fieldName, Object value); static Object invoke(Object receiver, String methodName, Object... arguments); static Object invokeStatic(String className, String methodName, Object... arguments); static Object invokeStatic(Class clazz, String methodName, Object... arguments); static Object newObject(String className, Object... args); static Method findMethod(Class clazz, String methodName, Class... argumentTypes); }
ReflectUtils { public static Object invokeStatic(String className, String methodName, Object... arguments) { try { Class clazz = Class.forName(className); return invokeStatic(clazz, methodName, arguments); } catch (ClassNotFoundException e) { e.printStackTrace(); } return null; }  static boolean hasClass(String className); static void setField(Object receiver, String fieldName, Object value); static Object invoke(Object receiver, String methodName, Object... arguments); static Object invokeStatic(String className, String methodName, Object... arguments); static Object invokeStatic(Class clazz, String methodName, Object... arguments); static Object newObject(String className, Object... args); static Method findMethod(Class clazz, String methodName, Class... argumentTypes);  }