Package org.allspice.util

Examples of org.allspice.util.ImmediateClassLoader.loadClass()


    JavaClass jc = GenJavaClass.createJavaClass(makeAddClass()) ;
    // Use a utility loader so we can call our class without saving to disk
    ImmediateClassLoader loader = new ImmediateClassLoader() ;
    loader.defineClass(jc.getClassName(),jc.getBytes()) ;
    // Load the honest to goodness class
    Class<?> cl = loader.loadClass("TestClass") ;
    // Create an instance of the class.
    Object o = cl.newInstance() ;
    // Get the "add" method
    Method m = cl.getMethod("add",int.class,int.class) ;
    // Run it!
View Full Code Here


  }
  public Class<?> makeClass(ClassDef cd) throws Exception {
    final JavaClass jc = GenJavaClass.createJavaClass(cd) ;
    ImmediateClassLoader loader = new ImmediateClassLoader() ;
    loader.defineClass(jc.getClassName(),jc.getBytes()) ;
    return loader.loadClass(cd.name.toString())
  }
  public Object makeObject(ClassDef cd) throws Exception {
    return makeClass(cd).newInstance() ;   
  }
View Full Code Here

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.