diff --git a/test/hotspot/jtreg/runtime/ClassUnload/ConstantPoolDependsTest.java b/test/hotspot/jtreg/runtime/ClassUnload/ConstantPoolDependsTest.java index a61c8cf4f2f..db490bd760a 100644 --- a/test/hotspot/jtreg/runtime/ClassUnload/ConstantPoolDependsTest.java +++ b/test/hotspot/jtreg/runtime/ClassUnload/ConstantPoolDependsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,6 +39,8 @@ import jdk.test.whitebox.WhiteBox; import jdk.test.lib.classloader.ClassUnloadCommon; import java.lang.ref.Reference; +import java.util.List; +import java.util.Set; public class ConstantPoolDependsTest { public static WhiteBox wb = WhiteBox.getWhiteBox(); public static final String MY_TEST = "ConstantPoolDependsTest$c1c"; @@ -78,10 +80,7 @@ public class ConstantPoolDependsTest { public static void main(String args[]) throws Throwable { test(); - ClassUnloadCommon.triggerUnloading(); // should unload - System.gc(); - System.out.println("Should unload p2.c2 just now"); - ClassUnloadCommon.failIf(wb.isClassAlive(MY_TEST), "should be unloaded"); - ClassUnloadCommon.failIf(wb.isClassAlive("p2.c2"), "should be unloaded"); + Set aliveClasses = ClassUnloadCommon.triggerUnloading(List.of(MY_TEST, "p2.c2")); + ClassUnloadCommon.failIf(!aliveClasses.isEmpty(), "should be unloaded: " + aliveClasses); } }