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

Kazuhisa Takakuri ktakakuri at openjdk.org
Fri Apr 11 09:13:41 UTC 2025


On Thu, 27 Mar 2025 00:42:52 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> test/hotspot/jtreg/runtime/os/windows/TestAvailableProcessors.java line 67:
>> 
>>> 65:         List<String> command = new ArrayList<>();
>>> 66:         // Force language to English before running systeminfo to get the OS version
>>> 67:         command.addAll(List.of("cmd.exe", "/c", "set", "PATH=%PATH%;C:\\Windows\\System32;C:\\Windows\\System32\\wbem", "&&"));
>> 
>> Not sure about hardcoding C:\Windows in tests as Windows could be installed on a different volume. Don't you need to use the value of %SystemRoot% to the directory?
>
> I thought it unfortunate that a path needed to be specified, but there is a precedent for assuming` C:\Windows`:
> 
> ./jdk/java/lang/ProcessHandle/ProcessUtil.java:   
>      return Platform.isWindows() && p.info().command().orElse("").endsWith("C:\\Windows\\System32\\conhost.exe");
> 
> though a more general approach would be similar to `./jdk/java/lang/RuntimeTests/exec/WinCommand.java`:
> 
>      File systemRoot =
>             getenv("SystemRoot") != null ? new File(getenv("SystemRoot")) :
>             getenv("WINDIR")     != null ? new File(getenv ("WINDIR")) :
>             null;
>         if (systemRoot == null || ! systemRoot.isDirectory())
>             return; // Not Windows as we know it
> 
>         String systemDirW = new File(systemRoot, "System32").getPath();
> 
> 
> I was also reminded that testing under non-US-English locales is not really supported:
> https://htmlpreview.github.io/?https://raw.githubusercontent.com/openjdk/jdk/master/doc/building.html#windows
>> The recommended and supported way of building the JDK on Windows is to set both the system locale and the user locale to US English. The system setting can be changed by going to the Control Panel, choosing "Regional Settings" -> "Administrative" and then pressing on the "Change System Locale" button.
>>
>> Since this is annoying for users who prefer another locale, we strive to get the building and testing to work on other locales as well. This is on a "best effort" level, so beware! You might get odd results in both building and testing. If you do, remember that locales other than US English are not supported nor recommended.
>>
>> It is also imperative to install the US English language pack in Visual Studio. For details, see [Microsoft Visual Studio](https://htmlpreview.github.io/?https://raw.githubusercontent.com/openjdk/jdk/master/doc/building.html#microsoft-visual-studio).

Thank you for your review. I changed it to use System.getenv().

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

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


More information about the hotspot-runtime-dev mailing list