RFR: 8344275: tools/jpackage/windows/Win8301247Test.java fails on localized Windows platform

Alexey Semenyuk asemenyuk at openjdk.org
Fri Nov 15 14:22:59 UTC 2024


On Fri, 15 Nov 2024 09:43:15 GMT, Taizo Kurashige <duke at openjdk.org> wrote:

> To resolve tools/jpackage/windows/Win8301247Test.java failure, I made "wmic" executed with "chcp 65001". This ensures that the encoding is UTF8 and that the English message "No Instance(s) Available." is output on localized windows platforms.
> 
> I have referred to the following for how to use chcp:
> ・chcp | Microsoft Learn at https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/chcp
> ・Code Page Identifiers - Win32 apps | Microsoft Learn at https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers
> 
> After fix, I ran tools/jpackage tests importing jdk.jpackage.test.Executor or jdk.jpackage.test.WindowsHelper.killAppLauncherProcess on Windows Server 2019 (Japanese and English locales). I confirmed that they pass.
> 
> Thanks

Changes requested by asemenyuk (Reviewer).

test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Executor.java line 344:

> 342:             command.add("cmd.exe");
> 343:             command.add("/c");
> 344:             command.add("chcp 65001 && " + printCommandLine(executablePath().toString(), args));

`printCommandLine()` function does a lousy job of escaping whitespaces in arguments. Its output is for logging purposes only. 

I experimented with the use of "chcp" in the "Executor" class and figured that it is not necessary to put the entire command line in a single argument. Please take a look at https://github.com/openjdk/jdk/commit/7975a8e97485b999691b986a78b1e0b47a9b30a1. It suppresses the output of "chcp" command, so client code may remain unchanged. Need to add the missing `setWinEnableUTF8()` and good to go.

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

PR Review: https://git.openjdk.org/jdk/pull/22142#pullrequestreview-2438749546
PR Review Comment: https://git.openjdk.org/jdk/pull/22142#discussion_r1843902329


More information about the core-libs-dev mailing list