|
Groovy example source code file (CompileOrderTest.groovy)
The Groovy CompileOrderTest.groovy source codepackage groovy class CompileOrderTest extends GroovyTestCase { public void testCompileOrder() { def interfaceFile = File.createTempFile("TestOrderInterface", ".groovy", new File("target")) def concreteFile = File.createTempFile("TestOrderConcrete", ".groovy", new File("target")) def cl = new GroovyClassLoader(this.class.classLoader); def currentDir = concreteFile.parentFile.absolutePath println currentDir cl.addClasspath(currentDir) cl.shouldRecompile = true try { // Create the interface println "a" interfaceFile.deleteOnExit() def interfaceName = interfaceFile.name - ".groovy" interfaceFile.write "interface $interfaceName { }\n" // Create a concrete class which implements the interface concreteFile.deleteOnExit() def concreteName = concreteFile.name - ".groovy" concreteFile.write "class $concreteName implements $interfaceName { }\n" // We're testing whether this fails: def groovyClass = cl.loadClass(concreteName,true,false) // Create an object, just for good measure. def object = groovyClass.newInstance() } finally { interfaceFile.delete() concreteFile.delete() } } } Other Groovy examples (source code examples)Here is a short list of links related to this Groovy CompileOrderTest.groovy 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.