diff --git a/make/RunTestsPrebuilt.gmk b/make/RunTestsPrebuilt.gmk index 7c1c55b2070..79c2828992a 100644 --- a/make/RunTestsPrebuilt.gmk +++ b/make/RunTestsPrebuilt.gmk @@ -216,9 +216,9 @@ else ifeq ($(OPENJDK_TARGET_OS), macosx) else ifeq ($(OPENJDK_TARGET_OS), windows) NUM_CORES := $(NUMBER_OF_PROCESSORS) MEMORY_SIZE := $(shell \ - $(EXPR) `wmic computersystem get totalphysicalmemory -value \ - | $(GREP) = | $(SED) 's/\\r//g' \ - | $(CUT) -d "=" -f 2-` / 1024 / 1024 \ + $(EXPR) `powershell -Command \ + "(Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory" \ + | $(SED) 's/\\r//g' ` / 1024 / 1024 \ ) endif ifeq ($(NUM_CORES), ) diff --git a/make/autoconf/build-performance.m4 b/make/autoconf/build-performance.m4 index 52d143e5ab9..9f3bbaa6f43 100644 --- a/make/autoconf/build-performance.m4 +++ b/make/autoconf/build-performance.m4 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2025, 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 @@ -85,7 +85,8 @@ AC_DEFUN([BPERF_CHECK_MEMORY_SIZE], FOUND_MEM=yes elif test "x$OPENJDK_BUILD_OS" = xwindows; then # Windows, but without cygwin - MEMORY_SIZE=`wmic computersystem get totalphysicalmemory -value | grep = | cut -d "=" -f 2-` + MEMORY_SIZE=`powershell -Command \ + "(Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory" | $SED 's/\\r//g' ` MEMORY_SIZE=`expr $MEMORY_SIZE / 1024 / 1024` FOUND_MEM=yes fi diff --git a/test/failure_handler/src/share/conf/windows.properties b/test/failure_handler/src/share/conf/windows.properties index cd45109a6d6..7e00a6cb9da 100644 --- a/test/failure_handler/src/share/conf/windows.properties +++ b/test/failure_handler/src/share/conf/windows.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2015, 2025, 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 @@ -22,10 +22,10 @@ # config.execSuffix=.exe -config.getChildren.app=bash +config.getChildren.app=powershell config.getChildren.pattern=%p -config.getChildren.args=-c\0wmic process where ParentProcessId=%p get ProcessId | tail -n+2 config.getChildren.args.delimiter=\0 +config.getChildren.args=-NoLogo\0-Command\0"Get-CimInstance Win32_Process -Filter \\\"ParentProcessId = %p\\\" | Select-Object ProcessId" | tail -n+4 ################################################################################ # process info to gather ################################################################################ @@ -39,8 +39,9 @@ native.pattern=%p native.javaOnly=false native.args=%p -native.info.app=wmic -native.info.args=process where processId=%p list full +native.info.app=powershell +native.info.delimiter=\0 +native.info.args=-NoLogo\0-Command\0"Get-WmiObject Win32_Process -Filter \\\"ProcessId = %p\\\" | Format-List -Property *" native.pmap.app=pmap native.pmap.normal.args=%p @@ -96,8 +97,9 @@ system.events.delimiter=\0 system.events.system.args=-NoLogo\0-Command\0Get-EventLog System -After (Get-Date).AddDays(-1) | Format-List system.events.application.args=-NoLogo\0-Command\0Get-EventLog Application -After (Get-Date).AddDays(-1) | Format-List -system.os.app=wmic -system.os.args=os get /format:list +system.os.app=powershell +system.os.delimiter=\0 +system.os.args=-NoLogo\0-Command\0Get-WmiObject Win32_OperatingSystem | Format-List -Property * process.top.app=top process.top.args=-b -n 1 diff --git a/test/jdk/tools/jpackage/windows/Win8301247Test.java b/test/jdk/tools/jpackage/windows/Win8301247Test.java index ed435bb9cc2..e820b42dc46 100644 --- a/test/jdk/tools/jpackage/windows/Win8301247Test.java +++ b/test/jdk/tools/jpackage/windows/Win8301247Test.java @@ -24,7 +24,6 @@ import java.io.IOException; import java.time.Duration; import java.util.List; -import java.util.NoSuchElementException; import java.util.Objects; import java.util.Optional; import java.util.concurrent.ExecutorService; @@ -100,40 +99,36 @@ public void test() throws IOException, InterruptedException { private static Optional findMainAppLauncherPID(JPackageCommand cmd, int expectedCount) { - // Get the list of PIDs and PPIDs of app launcher processes. - // wmic process where (name = "foo.exe") get ProcessID,ParentProcessID - List output = Executor.of("wmic", "process", "where", "(name", - "=", - "\"" + cmd.appLauncherPath().getFileName().toString() + "\"", - ")", "get", "ProcessID,ParentProcessID").dumpOutput(true). - saveOutput().executeAndGetOutput(); - - if (output.isEmpty()) { - throw new NoSuchElementException(); - } - String first = output.get(0); + // Get the list of PIDs and PPIDs of app launcher processes. Run setWinRunWithEnglishOutput(true) for JDK-8344275. + // powershell -NoLogo -NoProfile -NonInteractive -Command + // "Get-CimInstance Win32_Process -Filter \"Name = 'foo.exe'\" | select ProcessID,ParentProcessID" + String command = "Get-CimInstance Win32_Process -Filter \\\"Name = '" + + cmd.appLauncherPath().getFileName().toString() + + "'\\\" | select ProcessID,ParentProcessID"; + List output = Executor.of("powershell", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command", command) + .dumpOutput(true).saveOutput().executeAndGetOutput(); if (expectedCount == 0) { - TKit.assertEquals("No Instance(s) Available.", first. - trim(), "Check no app launcher processes found running"); - return Optional.empty(); + if (output.size() < 1) { + return Optional.empty(); + } } - String[] headers = Stream.of(first.split("\\s+", 2)).map( + String[] headers = Stream.of(output.get(1).split("\\s+", 2)).map( String::trim).map(String::toLowerCase).toArray(String[]::new); Pattern pattern; if (headers[0].equals("parentprocessid") && headers[1].equals( "processid")) { - pattern = Pattern.compile("^(?\\d+)\\s+(?\\d+)\\s+$"); + pattern = Pattern.compile("^\\s+(?\\d+)\\s+(?\\d+)$"); } else if (headers[1].equals("parentprocessid") && headers[0].equals( "processid")) { - pattern = Pattern.compile("^(?\\d+)\\s+(?\\d+)\\s+$"); + pattern = Pattern.compile("^\\s+(?\\d+)\\s+(?\\d+)$"); } else { throw new RuntimeException( - "Unrecognizable output of \'wmic process\' command"); + "Unrecognizable output of \'Get-CimInstance Win32_Process\' command"); } - List processes = output.stream().skip(1).map(line -> { + List processes = output.stream().skip(3).map(line -> { Matcher m = pattern.matcher(line); long[] pids = null; if (m.matches()) {