b3log版的反射ReflectHelper

来源:互联网 发布:数据库的设计步骤 编辑:程序博客网 时间:2024/05/21 00:56
public static String[] getMethodVariableNames(final Class<?> clazz, final String targetMethodName, final Class<?>[] types)
三个参数的意义
clazz类中,方法名为targetMethodName,该方法的参数为types,
返回的值

如果能找到这样的方法,返回参数的名字

有诗为证

import org.b3log.latke.util.ReflectHelper;public class testRefelctHelper {/** * @param args */public static void main(String[] args) {// TODO Auto-generated method stubtestReflectHelper2 kua=new testReflectHelper2();Class cha=kua.getClass();Integer zheng=new Integer(2);int zheng2=5;fuck who2=new fuck();Class<?>[] types={who2.getClass(),zheng.getClass()};String[] whatSThat=ReflectHelper.getMethodVariableNames(cha, "hongXing", types);System.out.println(whatSThat[0]);System.out.println(whatSThat[1]);}}
输出:

ShanShan
two_times

public class testReflectHelper2 {public Integer xueManZi(Integer i){return i;}public void liTianYi(fuck mengGe){}public void hongXing(fuck ShanShan,Integer two_times){}}
public class fuck {}

原创粉丝点击