package net.sf.joafip.classloader;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import net.sf.joafip.transformer.TestAction;
public final class MainClassLoader {
public static void main(final String[] args) {
MyClass myClass = new MyClass();
myClass.run();
ClassLoader base = ClassLoader.getSystemClassLoader();
// MyClassLoader myClassLoader = new MyClassLoader(base);
MyClassLoader myClassLoader = new MyClassLoader();
try {
final Class<?> clazz = myClassLoader
.loadClass("net.sf.joafip.classloader.MyClass");
Object instance = clazz.newInstance();
Method method = clazz.getMethod("run", new Class[] {});
method.invoke(instance, new Object[] {});
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
private void run() {
System.out.println(TestAction.class.getClassLoader());
TestAction x = new TestAction();
x.run();
}
}