Package net.sf.joafip.classloader

Source Code of net.sf.joafip.classloader.MainClassLoader

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();
  }
}
TOP

Related Classes of net.sf.joafip.classloader.MainClassLoader

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.