package introspection;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;

@Exercice(3)
public class LoadClass {

	/**
	 * @param args
	 * @throws MalformedURLException 
	 */
	public static void main(String[] args) throws MalformedURLException {
		URLClassLoader load=new URLClassLoader(new URL[] {new URL("http://igm.univ-mlv.fr/~lombardy/ens/JavaTTT/")});
		Class<?> c=null;
		try {
			c=load.loadClass("intros.MaClasse");
			Identity.displayID(c);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		try {
			Constructor<?> co = c.getConstructor(new Class<?>[] {});
			Method m= c.getMethod("toto", new Class<?>[]{long.class} );
			Object[] t={27L};
			m.invoke(co.newInstance(new Object[]{}), t);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
