Skip to content

Commit

Permalink
Call WhiteBox::fullGC() for class unloading
Browse files Browse the repository at this point in the history
  • Loading branch information
reinrich committed Jan 15, 2025
1 parent 2810d72 commit 9e524f9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions test/jdk/java/lang/String/concat/HiddenClassUnloading.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,20 @@
import java.lang.invoke.*;
import java.lang.management.ManagementFactory;

import jdk.test.whitebox.WhiteBox;

/**
* @test
* @summary Test whether the hidden class unloading of StringConcatFactory works
*
* @library /test/lib
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @requires vm.flagless
* @run main/othervm -Xmx8M -Xms8M -Xverify:all HiddenClassUnloading
* @run main/othervm -Xmx8M -Xms8M -Xverify:all -XX:-CompactStrings HiddenClassUnloading
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
* -Xverify:all HiddenClassUnloading
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
* -Xverify:all -XX:-CompactStrings HiddenClassUnloading
*/
public class HiddenClassUnloading {
public static void main(String[] args) throws Throwable {
Expand Down Expand Up @@ -61,6 +68,9 @@ public static void main(String[] args) throws Throwable {
);
}

// Request GC which performs class unloading
WhiteBox.getWhiteBox().fullGC();

long unloadedClassCount = ManagementFactory.getClassLoadingMXBean().getUnloadedClassCount();
if (initUnloadedClassCount == unloadedClassCount) {
throw new RuntimeException("unloadedClassCount is zero");
Expand Down

0 comments on commit 9e524f9

Please sign in to comment.