-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8337506: Disable "best-fit" mapping on Windows command line #20428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
👋 Welcome back naoto! A progress list of the required criteria for merging this PR into |
@naotoj 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:
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 56 new commits pushed to the
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. ➡️ To integrate this PR with the above commit message to the |
Webrevs
|
WC_NO_BEST_FIT_CHARS | WC_COMPOSITECHECK | WC_DEFAULTCHAR, | ||
wcCmdline, -1, NULL, 0, NULL, NULL); | ||
LPSTR mbCmdline = JLI_MemAlloc(mbSize); | ||
if (WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS | WC_COMPOSITECHECK | WC_DEFAULTCHAR, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks okay but will need to handle GetCommandLineW, WideCharToMultiByte, or JLI_MemAlloc failing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, all errors should be handled with the proposed patch. On error with JLI_MemAlloc and WideCharToMultiByte, the process exits with exit(1)
. As to GetCommandLineW()
, there is no description of error in the MS document (https://learn.microsoft.com/en-us/windows/win32/api/processenv/nf-processenv-getcommandlinew), so I suppose no error handling on our side is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, all errors should be handled with the proposed patch. On error with JLI_MemAlloc and WideCharToMultiByte, the process exits with
exit(1)
.
I think I'm mostly wondering about WideCharToMultiByte as it returns 0 when it fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first call to WideCharToMultiByte()
returns the required size for the multibyte buffer. When it returns 0, exit(1)
is issued inside JLI_MemAlloc()
. If the second call to WideCharToMultiByte()
returns 0, it is explicitly dealt with the patch which also issues exit(1)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first call to
WideCharToMultiByte()
returns the required size for the multibyte buffer. When it returns 0,exit(1)
is issued insideJLI_MemAlloc()
.
That's a bit subtle. I think it needs to be handled here or at least include a comment to say that it returns 0 on error which will cause JLI_MemAlloc to exit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, added the comment
/integrate |
Going to push as commit ff634a9.
Your commit was automatically rebased without conflicts. |
Fixing the Java launcher's command line argument parsing issue on Windows. The Java launcher on Windows has been using
GetCommandLineA()
to obtain arguments, which by default does "best-fit" mapping when the arguments are converted to ANSI code page encoding. By disabling this "best-fit" mapping, the launcher's parsing works as expected. A corresponding CSR has been drafted for the behavioral change.Progress
Issues
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/20428/head:pull/20428
$ git checkout pull/20428
Update a local copy of the PR:
$ git checkout pull/20428
$ git pull https://git.openjdk.org/jdk.git pull/20428/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 20428
View PR using the GUI difftool:
$ git pr show -t 20428
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/20428.diff
Webrev
Link to Webrev Comment