2626import java .lang .invoke .*;
2727import java .lang .management .ManagementFactory ;
2828
29+ import jdk .test .whitebox .WhiteBox ;
30+
2931/**
3032 * @test
3133 * @summary Test whether the hidden class unloading of StringConcatFactory works
3234 *
35+ * @library /test/lib
36+ * @build jdk.test.whitebox.WhiteBox
37+ * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
3338 * @requires vm.flagless
34- * @run main/othervm -Xmx8M -Xms8M -Xverify:all HiddenClassUnloading
35- * @run main/othervm -Xmx8M -Xms8M -Xverify:all -XX:-CompactStrings HiddenClassUnloading
39+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
40+ * -Xverify:all HiddenClassUnloading
41+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
42+ * -Xverify:all -XX:-CompactStrings HiddenClassUnloading
3643 */
3744public class HiddenClassUnloading {
3845 public static void main (String [] args ) throws Throwable {
@@ -43,7 +50,7 @@ public static void main(String[] args) throws Throwable {
4350
4451 long initUnloadedClassCount = ManagementFactory .getClassLoadingMXBean ().getUnloadedClassCount ();
4552
46- for (int i = 0 ; i < 12000 ; i ++) {
53+ for (int i = 0 ; i < 2000 ; i ++) {
4754 int radix = types .length ;
4855 String str = Integer .toString (i , radix );
4956 int length = str .length ();
@@ -61,6 +68,9 @@ public static void main(String[] args) throws Throwable {
6168 );
6269 }
6370
71+ // Request GC which performs class unloading
72+ WhiteBox .getWhiteBox ().fullGC ();
73+
6474 long unloadedClassCount = ManagementFactory .getClassLoadingMXBean ().getUnloadedClassCount ();
6575 if (initUnloadedClassCount == unloadedClassCount ) {
6676 throw new RuntimeException ("unloadedClassCount is zero" );
0 commit comments