mirror of
https://github.com/EsotericSoftware/reflectasm.git
synced 2025-01-28 12:50:23 +08:00
Try to fail less often (never?).
This commit is contained in:
parent
fdd38cafd1
commit
99cda2aa2a
@ -38,6 +38,7 @@ public class ClassLoaderTest extends TestCase {
|
||||
}
|
||||
|
||||
public void testAutoUnloadClassloaders () throws Exception {
|
||||
reclaimLoaders();
|
||||
int initialCount = AccessClassLoader.activeAccessClassLoaders();
|
||||
|
||||
ClassLoader testClassLoader1 = new TestClassLoader1();
|
||||
@ -70,6 +71,13 @@ public class ClassLoaderTest extends TestCase {
|
||||
testObject2 = null;
|
||||
access2 = null;
|
||||
|
||||
reclaimLoaders();
|
||||
|
||||
// Yeah, reclaimed!
|
||||
assertEquals(initialCount, AccessClassLoader.activeAccessClassLoaders());
|
||||
}
|
||||
|
||||
private void reclaimLoaders () throws Exception {
|
||||
// Force GC to reclaim unreachable (or only weak-reachable) objects
|
||||
System.gc();
|
||||
try {
|
||||
@ -84,9 +92,6 @@ public class ClassLoaderTest extends TestCase {
|
||||
Thread.sleep(100); // test again
|
||||
times++;
|
||||
}
|
||||
|
||||
// Yeah, both reclaimed!
|
||||
assertEquals(Math.min(initialCount, 1), AccessClassLoader.activeAccessClassLoaders());
|
||||
}
|
||||
|
||||
public void testRemoveClassloaders () throws Exception {
|
||||
|
Loading…
Reference in New Issue
Block a user