/******************************
* @author
* @date Feb 22, 2012 2:22:55 PM
* @version V1.0
*******************************/
import java.lang.reflect.Method;
public class Test2 {
public String f1(String xx, String ab) throws NullPointerException {
System.out.println("================sad" + xx);
if (xx == null)
throw new NullPointerException();
return xx;
}
public static void main(String args[]) {
try {
Class cls = Test2.class;
System.out.println("================1");
Object[] args1 = new Object[] {"tt","aa" };
Class[] argClass = new Class[args1.length];
for (int i = 0; i < args1.length; i++) {
argClass[i] = args1[i].getClass();
}
System.out.println("================2"+argClass.length);
Method m = cls.getMethod("f1", argClass);
System.out.println("================sad2");
m.invoke(new Test2(), args1);
} catch (Throwable e) {
System.err.println(e);
}
}
}
* @author
* @date Feb 22, 2012 2:22:55 PM
* @version V1.0
*******************************/
import java.lang.reflect.Method;
public class Test2 {
public String f1(String xx, String ab) throws NullPointerException {
System.out.println("================sad" + xx);
if (xx == null)
throw new NullPointerException();
return xx;
}
public static void main(String args[]) {
try {
Class cls = Test2.class;
System.out.println("================1");
Object[] args1 = new Object[] {"tt","aa" };
Class[] argClass = new Class[args1.length];
for (int i = 0; i < args1.length; i++) {
argClass[i] = args1[i].getClass();
}
System.out.println("================2"+argClass.length);
Method m = cls.getMethod("f1", argClass);
System.out.println("================sad2");
m.invoke(new Test2(), args1);
} catch (Throwable e) {
System.err.println(e);
}
}
}