Fix classloading integration tests

This commit is contained in:
Andrew Kent 2018-08-03 15:13:50 -07:00
parent 35c6fa2343
commit 260e3520aa
2 changed files with 7 additions and 5 deletions

View File

@ -56,6 +56,7 @@ class ClassLoadingTest extends Specification {
@Override
URL getResource(String name) {
count++
return super.getResource(name)
}
}
@ -65,10 +66,12 @@ class ClassLoadingTest extends Specification {
when:
loader.loadClass(ClassToInstrument.getName())
int countAfterFirstLoad = loader.count
loader.loadClass(ClassToInstrumentChild.getName())
then:
loader.count == 2
// ClassToInstrumentChild won't cause an additional getResource() because its TypeDescription is created from transformation bytes.
loader.count == countAfterFirstLoad
}
def "make sure that ByteBuddy doesn't resue cached type descriptions between different classloaders"() {
@ -81,8 +84,9 @@ class ClassLoadingTest extends Specification {
loader2.loadClass(ClassToInstrument.getName())
then:
loader1.count == 1
loader2.count == 1
loader1.count > 0
loader2.count > 0
loader1.count == loader2.count
}
def "can find bootstrap resources"() {

View File

@ -20,8 +20,6 @@ public class DDCachingPoolStrategy implements PoolStrategy {
synchronized (key) {
cache = typePoolCache.get(key);
if (null == cache) {
// new TypePool.Default.WithLazyResolution(TypePool.CacheProvider.Simple.withObjectType(),
// classFileLocator, TypePool.Default.ReaderMode.FAST);
cache = TypePool.CacheProvider.Simple.withObjectType();
typePoolCache.put(key, cache);
}