package first;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
class Test{
Test(){
System.out.println("Test()");
}
Test(int i,String str){
System.out.printf("Test:%d,%s/n",i,str);
}
}
public class ReflectTest {
/**
* @param args
*/
public static void main(String[] args) {
try {
System.out.println( Test.class.getCanonicalName());
Class cls = Class.forName("first.Test");
cls.newInstance();
Constructor con = cls.getConstructor(int.class,String.class);
Object obj = con.newInstance(2,"123456");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchMethodException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}