Skip to content

Conversation

@kurashige23
Copy link
Member

@kurashige23 kurashige23 commented Nov 15, 2024

To resolve tools/jpackage/windows/Win8301247Test.java failure, I made "wmic" executed with "chcp 437". This ensures 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


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8344275: tools/jpackage/windows/Win8301247Test.java fails on localized Windows platform (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22142/head:pull/22142
$ git checkout pull/22142

Update a local copy of the PR:
$ git checkout pull/22142
$ git pull https://git.openjdk.org/jdk.git pull/22142/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22142

View PR using the GUI difftool:
$ git pr show -t 22142

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22142.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 15, 2024

👋 Welcome back kurashige23! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Nov 15, 2024

@kurashige23 This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

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

Reviewed-by: asemenyuk, almatvee

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 29 new commits pushed to the master branch:

  • db44e97: 8344798: Shenandoah: Use more descriptive variable names in shPhaseTimings.cpp
  • c199f53: 8344336: SM cleanup of java.lang.System, Runtime, String, StackWalker
  • 0f458e2: 8342903: Deprecate for removal java.awt.Window.getWarningString()
  • efeacfe: 8344646: The libjsig deprecation warning should go to stderr not stdout
  • 2214906: 8272339: Update notes section from serialver man page
  • cee74f9: 8338536: Permanently disable remote code downloading in JNDI
  • 7709d43: 8344782: Cleanup left over doPrivileged calls and imports in java.desktop
  • e03b150: 8178966: Don't swallow early bootstrap exceptions in Boolean.getBoolean, Integer.getInteger and Long.getLong
  • d6b40d3: 8344144: AES/CBC slow at big payloads
  • 93d4ad4: 8344763: cpCache print_on doesn't handle nulls
  • ... and 19 more: https://git.openjdk.org/jdk/compare/a01aa2202602d2fcdb81b4c5b4183cb6b7acfacb...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@alexeysemenyukoracle, @sashamatveev) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 15, 2024
@openjdk
Copy link

openjdk bot commented Nov 15, 2024

@kurashige23 The following label will be automatically applied to this pull request:

  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the core-libs core-libs-dev@openjdk.org label Nov 15, 2024
@mlbridge
Copy link

mlbridge bot commented Nov 15, 2024

Webrevs

}

String[] headers = Stream.of(output.getFirst().split("\\s+", 2)).map(
String[] headers = Stream.of(output.get(1).split("\\s+", 2)).map(
Copy link
Member

@alexeysemenyukoracle alexeysemenyukoracle Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why look up the headers in the second line of the output?

Oh, this is because the first line of the output is "Active code page: 65001" coming from chcp 65001.
I'd run suppress the output of "chcp" command: chcp 65001 >nul 2>&1. This will make its usage transparent for the clients of the "Executor" class.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd run suppress the output of "chcp" command: chcp 65001 >nul 2>&1. This will make its usage transparent for the clients of the "Executor" class.

That's true. I added > nul2 > & 1 to suppress output of "chcp" command.

return this;
}

public Executor setWinEnableUTF8(boolean value) {
Copy link
Member

@alexeysemenyukoracle alexeysemenyukoracle Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function aims to make a to-be-executed command produce output in English. To achieve this goal implementation will call chcp 65001. The implementation may change, but the name of the function should remain the same. That said I suggest giving it a name that reflects its purpose and not the implementation. Something like: setWinRunWithEnglishOutput()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation may change, but the name of the function should remain the same.

That certainly makes sense. I changed setWinEnableUTF8 to setWinRunWithEnglishOutput as you suggested.

// run chcp to change the code page to UTF-8 on Windows
command.add("cmd.exe");
command.add("/c");
command.add("chcp 65001 && " + printCommandLine(executablePath().toString(), args));
Copy link
Member

@alexeysemenyukoracle alexeysemenyukoracle Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 7975a8e. It suppresses the output of "chcp" command, so client code may remain unchanged. Need to add the missing setWinEnableUTF8() and good to go.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the incorrect use of printCommandLine().

As I checked, I could certainly execute "chcp" without putting the entire command line in a single argument. I fixed referring to 7975a8e. Thanks.

@alexeysemenyukoracle
Copy link
Member

alexeysemenyukoracle commented Nov 15, 2024

I'm not sure "65001" is the right choice if the request is to get the output in English. Would "437" or "850" be more appropriate arguments for the "chcp" command?

@openjdk
Copy link

openjdk bot commented Nov 20, 2024

⚠️ @kurashige23 This pull request contains merges that bring in commits not present in the target repository. Since this is not a "merge style" pull request, these changes will be squashed when this pull request in integrated. If this is your intention, then please ignore this message. If you want to preserve the commit structure, you must change the title of this pull request to Merge <project>:<branch> where <project> is the name of another project in the OpenJDK organization (for example Merge jdk:master).

var cmdline = Stream.of(prefixCommandLineArgs(), List.of(exec), args).flatMap(
List::stream).toList();

return String.format(format, printCommandLine(cmdline), cmdline.size() + 1);
Copy link
Member

@alexeysemenyukoracle alexeysemenyukoracle Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmdline.size() + 1 seems to be wrong. It should be cmdline.size().
+ 1 was needed previously when was applied to the args.size() that didn't count the executable. Sorry, I oversaw this thing in my patch.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I understood why + 1 is not needed. I removed + 1.


private List<String> prefixCommandLineArgs() {
if (winEnglishOutput) {
return List.of("cmd.exe", "/c", "chcp", "437", ">nul", "2>&1", "&&");
Copy link
Member

@alexeysemenyukoracle alexeysemenyukoracle Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume chcp 437 works as expected. The summary still references chcp 65001 command.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I confirmed that it works as expected.

The summary still references chcp 65001 command.

Thanks, I fixed summary.

@kurashige23
Copy link
Member Author

I'm not sure "65001" is the right choice if the request is to get the output in English. Would "437" or "850" be more appropriate arguments for the "chcp" command?

After receiving your comment, I ran the chcp command on Windows Server 2019 (English locale) and the active code page was 437.
For this reason, I think 437 is more appropriate.
I changed code page from 65001 to 437.

@kurashige23
Copy link
Member Author

After making these fixes, I ran tools/jpackage tests importing Executor or WindowsHelper.killAppLauncherProcess on Windows Server 2019 (Japanese and English locales). I confirmed that they pass.

@alexeysemenyukoracle
Copy link
Member

Thank you for working on this patch!

@openjdk
Copy link

openjdk bot commented Nov 20, 2024

@kurashige23 this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout fix_Win8301247Test_bug
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Nov 20, 2024
@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label Nov 21, 2024
@openjdk
Copy link

openjdk bot commented Nov 21, 2024

@kurashige23 Changes in this repository do not require maintainer approval.

@kurashige23
Copy link
Member Author

Sorry, I fixed conflict. Please review again.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 21, 2024
Copy link
Member

@sashamatveev sashamatveev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@kurashige23
Copy link
Member Author

Thank you for your review.

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Nov 22, 2024
@openjdk
Copy link

openjdk bot commented Nov 22, 2024

@kurashige23
Your change (at version f013d9f) is now ready to be sponsored by a Committer.

@victordyakov
Copy link

@alexeysemenyukoracle could you please sponsor this?

@alexeysemenyukoracle
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Nov 25, 2024

Going to push as commit 48e3b65.
Since your change was applied there have been 85 commits pushed to the master branch:

  • 1623257: 8339524: Clean up a few ExtendedRobot tests
  • 0276079: 8344667: Remove most uses of AWT Permissions from the desktop module
  • 8de158a: 8339134: Callers of Exceptions::fthrow should ensure exception message lengths avoid the INT_MAX limits of os::vsnprintf
  • df2d4c1: 8344898: SM cleanup of java.base sun/util calendar, locale, cldr, and resources
  • 4d898aa: 8344896: Remove obsolete checks for AWTPermission accessClipboard
  • 08dfc4a: 8344213: Cleanup OpaqueLoop*Node verification code for Assertion Predicates
  • 593a589: 8344319: SM cleanup in jdk.dynalink module
  • 15ae8d0: 8319993: Update Unicode Data Files to 16.0.0
  • a032de2: 8344577: Virtual thread tests are timing out on some macOS systems
  • 4110d39: 8344865: SM cleanup in sun/reflect/annotation
  • ... and 75 more: https://git.openjdk.org/jdk/compare/a01aa2202602d2fcdb81b4c5b4183cb6b7acfacb...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Nov 25, 2024
@openjdk openjdk bot closed this Nov 25, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Nov 25, 2024
@openjdk
Copy link

openjdk bot commented Nov 25, 2024

@alexeysemenyukoracle @kurashige23 Pushed as commit 48e3b65.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

4 participants