import java.lang.reflect.Method;public class ApplicationRun
{ public void run(String className) throws Exception
{
Class<?> cl = Class.forName(className);
Method[] methods =null; if (cl.isAnnotationPresent(Test.class))
{ methods = cl.getMethods(); }
System.out.println(methods);
for (Method me : methods)
{
me.setAccessible(true);
me.invoke( className, null);
} }
}我想运行实例的这些符合要求的方法:
1.用public void修饰的
2.用“Test”注释过的我也不清楚这一段代码 各位大牛们看得懂我的意思麽,要是题意不清楚的我再补充。谢谢嘞
但是没有判断方法的修饰符和返回值。getModifiers() 返回一个常量等于Modifier.PUBLIC。getReturnType()返回方法返回值 ,可以查查API