On Fri, 2 Aug 2024 09:30:56 GMT, Alan Bateman <al...@openjdk.org> wrote:
>> 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. > > src/java.base/share/native/launcher/main.c line 121: > >> 119: wcCmdline, -1, NULL, 0, NULL, NULL); >> 120: LPSTR mbCmdline = JLI_MemAlloc(mbSize); >> 121: if (WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS | >> WC_COMPOSITECHECK | WC_DEFAULTCHAR, > > I think this looks okay but will need to handle GetCommandLineW, > WideCharToMultiByte, or JLI_MemAlloc failing. 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. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/20428#discussion_r1702102957