|
Groovy example source code file (WeakMapTest.groovy)
The Groovy WeakMapTest.groovy source codepackage org.codehaus.groovy.reflection class WeakMapTest extends GroovyTestCase{ void testClassUnload () { GroovyShell shell = null int SIZE = 1000 for (int i = 0; i != SIZE; ++i) { if (shell == null) shell = new GroovyShell () Script s = shell.parse (""" class A extends B { def String callMe (b) { b instanceof A ? this : b } } class B { } new A ().callMe ("lambda") """) s.run() ReflectionCache.isAssignableFrom s.class, s.class.superclass if (i % 10 == 0) { if (i % 50 == 0) shell = null System.gc () } if (shell != null) shell.classLoader.clearCache() GroovySystem.metaClassRegistry.removeMetaClass s.class.superclass GroovySystem.metaClassRegistry.removeMetaClass s.class } println "${SIZE} ${ClassInfo.size()}" } } Other Groovy examples (source code examples)Here is a short list of links related to this Groovy WeakMapTest.groovy source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 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.