From 30c94906fe8fd65ba21fe95a66ae7da7d7ca5e4a Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Wed, 13 Mar 2024 11:22:40 +0000 Subject: [PATCH 1/4] Backport da4dd7c008da4be54ee5f58d1ac19f440fd2a74e --- test/jdk/java/net/httpclient/ManyRequests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/jdk/java/net/httpclient/ManyRequests.java b/test/jdk/java/net/httpclient/ManyRequests.java index 55be2d56bab..51bbcb8c615 100644 --- a/test/jdk/java/net/httpclient/ManyRequests.java +++ b/test/jdk/java/net/httpclient/ManyRequests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -166,7 +166,7 @@ static void test(HttpsServer server, HttpClient client) throws Exception { URI baseURI = URIBuilder.newBuilder() .scheme("https") - .host(InetAddress.getLoopbackAddress().getHostName()) + .loopback() .port(port) .path("/foo/x").build(); server.createContext("/foo", new TestEchoHandler()); From fa0600de9a16a95534cd2fa50b1760911365c4fa Mon Sep 17 00:00:00 2001 From: Brent Christian Date: Fri, 25 Apr 2025 17:06:26 +0000 Subject: [PATCH 2/4] Backport d8f012ea2a0514020434d5db6047e36941e9349b --- test/lib/sun/hotspot/WhiteBox.java | 57 +++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/test/lib/sun/hotspot/WhiteBox.java b/test/lib/sun/hotspot/WhiteBox.java index feae1ed8e2f..70a369ea27a 100644 --- a/test/lib/sun/hotspot/WhiteBox.java +++ b/test/lib/sun/hotspot/WhiteBox.java @@ -24,7 +24,11 @@ package sun.hotspot; import java.lang.management.MemoryUsage; +import java.lang.ref.Reference; import java.lang.reflect.Executable; +import java.lang.reflect.InaccessibleObjectException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.Arrays; import java.util.List; import java.util.function.BiFunction; @@ -400,10 +404,55 @@ public void clearInlineCaches(boolean preserve_static_stubs) { // Force Full GC public native void fullGC(); - // Returns true if the current GC supports control of its concurrent - // phase via requestConcurrentGCPhase(). If false, a request will - // always fail. - public native boolean supportsConcurrentGCPhaseControl(); + // Infrastructure for waitForReferenceProcessing() + private static volatile Method waitForReferenceProcessingMethod = null; + + private static Method getWaitForReferenceProcessingMethod() { + Method wfrp = waitForReferenceProcessingMethod; + if (wfrp == null) { + try { + wfrp = Reference.class.getDeclaredMethod("waitForReferenceProcessing"); + wfrp.setAccessible(true); + assert wfrp.getReturnType() == Boolean.class; + Class[] ev = wfrp.getExceptionTypes(); + assert ev.length == 1; + assert ev[0] == InterruptedException.class; + waitForReferenceProcessingMethod = wfrp; + } catch (InaccessibleObjectException e) { + throw new RuntimeException("Need to add @modules java.base/java.lang.ref:open to test?", e); + } catch (NoSuchMethodException e) { + throw new RuntimeException(e); + } + } + return wfrp; + } + + /** + * Wait for reference processing, via Reference.waitForReferenceProcessing(). + * Callers of this method will need the + * @modules java.base/java.lang.ref:open + * jtreg tag. + * + * This method should usually be called after a call to WhiteBox.fullGC(). + */ + public boolean waitForReferenceProcessing() throws InterruptedException { + try { + Method wfrp = getWaitForReferenceProcessingMethod(); + return (Boolean) wfrp.invoke(null); + } catch (IllegalAccessException e) { + throw new RuntimeException("Shouldn't happen, we call setAccessible()", e); + } catch (InvocationTargetException e) { + Throwable cause = e.getCause(); + if (cause instanceof InterruptedException) { + throw (InterruptedException) cause; + } else { + throw new RuntimeException(e); + } + } + } + + // Returns true if the current GC supports concurrent collection control. + public native boolean supportsConcurrentGCBreakpoints(); // Returns an array of concurrent phase names provided by this // collector. These are the names recognized by From d37c4a669f877dcb04eb08435964658adfcf0657 Mon Sep 17 00:00:00 2001 From: SendaoYan Date: Mon, 20 Oct 2025 14:14:55 +0000 Subject: [PATCH 3/4] Revert "Backport da4dd7c008da4be54ee5f58d1ac19f440fd2a74e" This reverts commit 30c94906fe8fd65ba21fe95a66ae7da7d7ca5e4a. --- test/jdk/java/net/httpclient/ManyRequests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/jdk/java/net/httpclient/ManyRequests.java b/test/jdk/java/net/httpclient/ManyRequests.java index 51bbcb8c615..55be2d56bab 100644 --- a/test/jdk/java/net/httpclient/ManyRequests.java +++ b/test/jdk/java/net/httpclient/ManyRequests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2018, 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 @@ -166,7 +166,7 @@ static void test(HttpsServer server, HttpClient client) throws Exception { URI baseURI = URIBuilder.newBuilder() .scheme("https") - .loopback() + .host(InetAddress.getLoopbackAddress().getHostName()) .port(port) .path("/foo/x").build(); server.createContext("/foo", new TestEchoHandler()); From 7709c20d56e392480ea6121e943e526ea3e189e3 Mon Sep 17 00:00:00 2001 From: SendaoYan Date: Mon, 20 Oct 2025 14:18:54 +0000 Subject: [PATCH 4/4] Revert change of supportsConcurrentGCPhaseControl --- test/lib/sun/hotspot/WhiteBox.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/lib/sun/hotspot/WhiteBox.java b/test/lib/sun/hotspot/WhiteBox.java index 70a369ea27a..cd97debd33b 100644 --- a/test/lib/sun/hotspot/WhiteBox.java +++ b/test/lib/sun/hotspot/WhiteBox.java @@ -404,6 +404,11 @@ public void clearInlineCaches(boolean preserve_static_stubs) { // Force Full GC public native void fullGC(); + // Returns true if the current GC supports control of its concurrent + // phase via requestConcurrentGCPhase(). If false, a request will + // always fail. + public native boolean supportsConcurrentGCPhaseControl(); + // Infrastructure for waitForReferenceProcessing() private static volatile Method waitForReferenceProcessingMethod = null; @@ -451,9 +456,6 @@ public boolean waitForReferenceProcessing() throws InterruptedException { } } - // Returns true if the current GC supports concurrent collection control. - public native boolean supportsConcurrentGCBreakpoints(); - // Returns an array of concurrent phase names provided by this // collector. These are the names recognized by // requestConcurrentGCPhase().