From bf52eb035865353fdf5c6c242f9676a51dcc9e22 Mon Sep 17 00:00:00 2001 From: Brent Christian Date: Tue, 29 Apr 2025 20:15:00 +0000 Subject: [PATCH] 8355632: WhiteBox.waitForReferenceProcessing() fails assert for return type Reviewed-by: kbarrett --- .../jdk/test/whitebox/WaitForRefProcTest.java | 30 +++++++++++++++++++ test/lib/jdk/test/whitebox/WhiteBox.java | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 test/lib-test/jdk/test/whitebox/WaitForRefProcTest.java diff --git a/test/lib-test/jdk/test/whitebox/WaitForRefProcTest.java b/test/lib-test/jdk/test/whitebox/WaitForRefProcTest.java new file mode 100644 index 00000000000..1a254775f77 --- /dev/null +++ b/test/lib-test/jdk/test/whitebox/WaitForRefProcTest.java @@ -0,0 +1,30 @@ +/* + * @test + * @summary Test WhiteBox.waitForReferenceProcessing + * @bug 8305186 8355632 + * @library /test/lib + * @build jdk.test.whitebox.WhiteBox + * @modules java.base/java.lang.ref:open + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * @run main/othervm -ea -esa + * -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions + * -XX:+WhiteBoxAPI + * WaitForRefProcTest + */ + +import jdk.test.whitebox.WhiteBox; + +public class WaitForRefProcTest { + + public static void main(String[] args) { + WhiteBox.getWhiteBox().fullGC(); + try { + boolean ret = WhiteBox.getWhiteBox().waitForReferenceProcessing(); + System.out.println("wFRP returned " + ret); + } catch (InterruptedException e) { + e.printStackTrace(); + throw new RuntimeException("test caught InterruptedException"); + } + } +} diff --git a/test/lib/jdk/test/whitebox/WhiteBox.java b/test/lib/jdk/test/whitebox/WhiteBox.java index bd68cf72cc3..4747740274e 100644 --- a/test/lib/jdk/test/whitebox/WhiteBox.java +++ b/test/lib/jdk/test/whitebox/WhiteBox.java @@ -569,7 +569,7 @@ public class WhiteBox { try { wfrp = Reference.class.getDeclaredMethod("waitForReferenceProcessing"); wfrp.setAccessible(true); - assert wfrp.getReturnType() == Boolean.class; + assert wfrp.getReturnType().equals(boolean.class); Class[] ev = wfrp.getExceptionTypes(); assert ev.length == 1; assert ev[0] == InterruptedException.class;