package pr2.reflection.reflector;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Reflector {

    public static void main(String[] args) throws ClassNotFoundException,
            SecurityException, NoSuchMethodException, IllegalArgumentException,
            InstantiationException, IllegalAccessException,
            InvocationTargetException {

        Class<?> clazz = Class.forName("java.util.Date");
        Constructor<?> constructor = clazz.getConstructor();
        Object o = constructor.newInstance((Object[]) null);
        Method toString = clazz.getMethod("toString");
        Object result = toString.invoke(o, (Object[]) null);
        System.out.println(result);
    }
}
