Java反射工具类 (三)

2014-11-24 03:14:16 · 作者: · 浏览: 2
数以,形式分割

meth = meth.substring(meth.indexOf("(") + 1, meth.indexOf(")"));

// ret由3部分构成:参数;方法名;返回类型

String ret = meth + ";" + m[i].getName() + ";" + m[i].getReturnType();

retValue.add(ret);

}

return retValue;

}

catch (ClassNotFoundException e) {

e.printStackTrace();

}

return retValue;

}

// http://zhidao.baidu.com/question/151090808.html

// public static void main(String args[]) {

// getMe();

// }

//

// public static void getMethod() {

// try {

// Class cls = Class.forName("com.epoint.utility.xml.ReadXML");

// Method methlist[] = cls.getDeclaredMethods();

//

// for (int i = 0; i < methlist.length; i++) {

// Method m = methlist[i];

// System.out.println("name= " + m.getName());

// Class pvec[] = m.getParameterTypes();

// for (int j = 0; j < pvec.length; j++) {

// System.out.println("param #" + j + " " + pvec[j]);

// }

// Class evec[] = m.getExceptionTypes();

// for (int j = 0; j < evec.length; j++) {

// System.out.println("exc #" + j + " " + evec[j]);

// }

// System.out.println("return type = " + m.getReturnType());

// System.out.println("-----");

// }

// }

//

// catch (Throwable e) {

//

// System.err.println(e);

//

// }

//

// }

//

// public static void getMe() {

// try {

// Class cls = Class.forName("com.epoint.utility.xml.ReadXML");

// Constructor ctorlist[] = cls.getDeclaredConstructors();

// for (int i = 0; i < ctorlist.length; i++) {

// Constructor ct = ctorlist[i];

// System.out.println("name = " + ct.getName());

// Class pvec[] = ct.getParameterTypes();

// for (int j = 0; j < pvec.length; j++) {

// System.out.println("param #" + j + " " + pvec[j]);

// }

// Class evec[] = ct.getExceptionTypes();

// for (int j = 0; j < evec.length; j++) {

// System.out.println("exc #" + j + " " + evec[j]);

// }

// System.out.println("-----");

// }

// }

// catch (Throwable e) {

// System.err.println(e);

// }

//

// }

}

作者 月写意&随月