8276819: javax/print/PrintServiceLookup/FlushCustomClassLoader.java fails to free

Backport-of: 7c2c58587d4eda5523331eae45e7d897252dc097
This commit is contained in:
Sergey Bylokhov 2022-02-17 04:50:50 +00:00
parent 09dfa48cda
commit 525f17fe15

View File

@ -34,6 +34,9 @@ import javax.print.PrintServiceLookup;
* @test
* @bug 8273831
* @summary Tests custom class loader cleanup
* @library /javax/swing/regtesthelpers
* @build Util
* @run main/timeout=60/othervm -mx32m FlushCustomClassLoader
*/
public final class FlushCustomClassLoader {
@ -42,12 +45,8 @@ public final class FlushCustomClassLoader {
int attempt = 0;
while (loader.get() != null) {
if (++attempt > 10) {
throw new RuntimeException("Too many attempts: " + attempt);
}
System.gc();
Thread.sleep(1000);
System.out.println("Not freed, attempt: " + attempt);
Util.generateOOME();
System.out.println("Not freed, attempt: " + attempt++);
}
}