From 4babac728f7182d49f8ad3fdd966bae9e19dfe37 Mon Sep 17 00:00:00 2001 From: Saint Wesonga Date: Fri, 1 Nov 2024 11:02:46 -0600 Subject: [PATCH] Remove calls to APIs unavailable in jdk17u (#30) --- .../runtime/os/windows/TestAvailableProcessors.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/test/hotspot/jtreg/runtime/os/windows/TestAvailableProcessors.java b/test/hotspot/jtreg/runtime/os/windows/TestAvailableProcessors.java index f7dc237d07d..7a897599d55 100644 --- a/test/hotspot/jtreg/runtime/os/windows/TestAvailableProcessors.java +++ b/test/hotspot/jtreg/runtime/os/windows/TestAvailableProcessors.java @@ -38,6 +38,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.HashSet; import java.util.Set; @@ -66,7 +67,7 @@ private static String getWindowsVersion() throws IOException { OutputAnalyzer outputAnalyzer = new OutputAnalyzer(processBuilder.start()); outputAnalyzer.shouldHaveExitValue(0); outputAnalyzer.shouldContain(osVersionMessage); - List lines = outputAnalyzer.stdoutAsLines(); + List lines = asLines(outputAnalyzer.getStdout()); String osVersion = null; for (var line: lines) { @@ -80,6 +81,10 @@ private static String getWindowsVersion() throws IOException { return osVersion; } + private static List asLines(String buffer) { + return Arrays.asList(buffer.split("\\R")); + } + private static boolean getSchedulesAllProcessorGroups(boolean isWindowsServer) throws IOException { String windowsVer = getWindowsVersion(); String[] parts = windowsVer.split(" "); @@ -115,7 +120,7 @@ private static boolean getSchedulesAllProcessorGroups(boolean isWindowsServer) t private static OutputAnalyzer getAvailableProcessorsOutput(boolean productFlagEnabled) throws IOException { String productFlag = productFlagEnabled ? "-XX:+UseAllWindowsProcessorGroups" : "-XX:-UseAllWindowsProcessorGroups"; - ProcessBuilder processBuilder = ProcessTools.createLimitedTestJavaProcessBuilder( + ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder( new String[] {productFlag, "GetAvailableProcessors"} ); @@ -128,7 +133,7 @@ private static OutputAnalyzer getAvailableProcessorsOutput(boolean productFlagEn private static int getAvailableProcessors(OutputAnalyzer outputAnalyzer) { int runtimeAvailableProcs = 0; - List output = outputAnalyzer.stdoutAsLines(); + List output = asLines(outputAnalyzer.getStdout()); for (var line: output) { if (line.startsWith(runtimeAvailableProcessorsMessage)) { @@ -188,7 +193,7 @@ private static void testProcessorAvailability() throws IOException { boolean isWindowsServer = false; var processorGroupSizes = new HashSet(); - List lines = outputAnalyzer.stdoutAsLines(); + List lines = asLines(outputAnalyzer.getStdout()); for (var line: lines) { if (line.startsWith(totalProcessorCountMessage)) {