|
Groovy example source code file (LazyInitOnClassNodeTest.groovy)
The Groovy LazyInitOnClassNodeTest.groovy source codeimport org.codehaus.groovy.ast.* class LazyInitOnClassNodeTest extends GroovyTestCase { void testLazyInit() { def script = """ class ClassNodeMethodsListGrowth { // Setting the type to ArrayList triggers a growth in methodsList ArrayList array1=new ArrayList() // ... using dynamic typing does not // def array2=new ArrayList() // Test method as a sanity check def get(o) { return "ok" } } """ def listType = ClassHelper.make(List.class) def last=0 5.times { def loader = new GroovyClassLoader(this.class.classLoader) assert loader.parseClass(script).newInstance().get("default")=="ok" def size = listType.redirect().getMethods().size() if (last!=0) assert last==size if (last==0) last = size } } } Other Groovy examples (source code examples)Here is a short list of links related to this Groovy LazyInitOnClassNodeTest.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.