首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

getmethod方法_method的值有哪些

Method getMethod(String name, Class>… parameterTypes) –返回一个 Method 对象,它反映此 Class 对象所表示的类或接口的指定公共成员方法。...方法后面接收的就是Class类的对象,而如:String.class、int.class这些字节码才是Class类的对象 也可以此种方式: //getMethod第一个参数是方法名,第二个参数是该方法的参数类型..., //因为存在同方法名不同参数这种情况,所以只有同时指定方法名和参数类型才能唯一确定一个方法 Method method = XXX.getClass().getMethod(methodName,new...Class[0]); //第一个参数是具体调用该方法的对象 //第二个参数是执行该方法的具体参数 如一个函数 int Test(int a, String str); 对应的getMethod方法:...getMethod(“Test”,int.class,String.class); 2. getMethod(“Test”,new Class[]{int.class,String.class}); 然后通过

49120

初探java安全之反射(2)

重要方法 其实上篇总结过,这里再加几个 获取类的方法 foName 实例化类对象的方法 newInstance 获取函数的方法 getMethod 执行函数的方法 invoke 获得构造方法 getConstructor...java执行命令 Runtime run = Runtime.getRuntime();//获取 Runtime 对象 run.exec("calc");//执行calc命令弹出计算器 getMethod...("exec", String.class); invoke() invoke() 方法用于执行 getMethod 获取的方法,看看它的相关参数 第一个参数是函数所在的对象或**类(执行静态方法可用...所以可以利用纯反射执行吗,命令 //获取 Runtime 类 Class clazz = Class.forName("java.lang.Runtime"); clazz.getMethod("exec...").getMethod("exec", String.class).invoke(Class.forName("java.lang.Runtime").getMethod("getRuntime").

41140
领券