|
Groovy example source code file (TestDgmConverter.java)
The Groovy TestDgmConverter.java source codepackage org.codehaus.groovy.tools; import groovy.lang.MetaMethod; import junit.framework.TestCase; import org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl; import java.io.File; public class TestDgmConverter extends TestCase { public void testConverter () { final File[] files = new File("target/classes/org/codehaus/groovy/runtime").listFiles(); for (int i = 0; i < files.length; i++) { File file = files[i]; final String name = file.getName(); if (name.startsWith("dgm$")) { System.out.println(name); final String className = "org.codehaus.groovy.runtime." + name.substring(0, name.length() - ".class".length()); try { Class cls = Class.forName(className); final MetaMethod metaMethod = (MetaMethod) cls.newInstance(); System.out.println(metaMethod); } catch (ClassNotFoundException e) { fail("Failed to load " + className); } catch (IllegalAccessException e) { fail("Failed to instantiate " + className); } catch (InstantiationException e) { fail("Failed to instantiate " + className); } } } } public void testRegistry () { final MetaClassRegistryImpl metaClassRegistry = new MetaClassRegistryImpl(); final Object [] instanceMethods = metaClassRegistry.getInstanceMethods().getArray(); for (int i = 0; i < instanceMethods.length; i++) { System.out.println(instanceMethods[i]); } } } Other Groovy examples (source code examples)Here is a short list of links related to this Groovy TestDgmConverter.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.