1 46 47 package org.codehaus.groovy.classgen; 48 49 import groovy.lang.GroovyObject; 50 import groovy.lang.MetaClass; 51 52 import java.io.File ; 53 54 55 61 public class GroovyClassLoaderTest extends TestSupport { 62 63 public void testCompile() throws Exception { 64 Class groovyClass = loader.parseClass(new File ("src/test/org/codehaus/groovy/classgen/Main.groovy")); 65 66 System.out.println("Invoking main..."); 67 68 GroovyObject object = (GroovyObject) groovyClass.newInstance(); 69 70 assertTrue(object != null); 71 72 MetaClass metaClass = object.getMetaClass(); 73 System.out.println("Metaclass: " + metaClass); 74 75 Class type = object.getClass(); 76 System.out.println("Type: " + type); 77 78 metaClass.invokeMethod(object, "main", null); 80 81 object.invokeMethod("main", null); 83 } 84 } 85 | Popular Tags |