RFR: 8349288: runtime/os/windows/TestAvailableProcessors.java fails on localized Windows platform [v8]

Alan Bateman alanb at openjdk.org
Fri Jun 20 09:30:32 UTC 2025


On Fri, 6 Jun 2025 08:21:08 GMT, Kazuhisa Takakuri <ktakakuri at openjdk.org> wrote:

>> To resolve runtime/os/windows/TestAvailableProcessors.java failure, I made "systeminfo.exe" executed with "chcp 437". This ensures that the English message "OS Version: " is output on localized windows platforms.
>> I added the path C:\Windows\System32 to make chcp command recognized on the GHA Windows test machine. Without this addition, GHA will fail.
>> After this fix, I verified that the test passed.
>> 
>> https://github.com/openjdk/jdk/pull/22142
>> I refer to this fix.
>> tools/jpackage/windows/Win8301247Test.java does not run in GHA, so the problems with recognition of chcp command did not occur before.
>> 
>> Thanks.
>
> Kazuhisa Takakuri has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8349288: runtime/os/windows/TestAvailableProcessors.java fails on localized Windows platform

test/hotspot/jtreg/runtime/os/windows/TestAvailableProcessors.java line 75:

> 73:             throw new RuntimeException("SystemRoot or WINDIR environment variable is not set.");
> 74:         }
> 75:         String systemDirW = new File(systemRoot, "System32").getPath();

A drive-by comment is that you could remove the duplicate calls to getenv and just use a simple Path resolve. e.g.

        String systemRoot = System.getenv("SystemRoot");
        if (systemRoot == null) {
            systemRoot = System.getenv("WINDIR");
            if (systemRoot == null) {
                // throw
            }
        }
        String system32 = Path.of(systemRoot, "System32").toString();

test/hotspot/jtreg/runtime/os/windows/TestAvailableProcessors.java line 80:

> 78:         command.addAll(List.of("cmd.exe", "/c", "set", "PATH=%PATH%;" + systemDirW + ";" + systemDirW + "\\wbem", "&&"));
> 79:         command.addAll(List.of("chcp", "437", ">nul", "2>&1", "&&"));
> 80:         command.add(systeminfoPath);

I assume it would be more correct to say that it switches the active code page to cp437, the default code page for US english.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/23536#discussion_r2158463587
PR Review Comment: https://git.openjdk.org/jdk/pull/23536#discussion_r2158469970


More information about the hotspot-runtime-dev mailing list