8355249: Remove the use of WMIC from the entire source code

Reviewed-by: phh
Backport-of: 4458719a108f45d3744d47a6ea081fe9ec3e675e
This commit is contained in:
Taizo Kurashige 2025-08-11 17:53:29 +00:00 committed by Paul Hohensee
parent 5b0c2800df
commit d2a17d1acc
3 changed files with 15 additions and 12 deletions

View File

@ -239,9 +239,9 @@ else ifeq ($(OPENJDK_TARGET_OS), solaris)
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), )

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2019, 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
@ -84,7 +84,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

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2015, 2020, 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
@ -89,8 +90,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