RFR: 8346719: Add relaunchers to the static JDK image for missing executables [v9]
Alexey Semenyuk
asemenyuk at openjdk.org
Wed Sep 17 15:26:28 UTC 2025
On Wed, 17 Sep 2025 14:51:46 GMT, Magnus Ihse Bursie <ihse at openjdk.org> wrote:
>> src/java.base/windows/native/launcher/relauncher.c line 153:
>>
>>> 151: }
>>> 152:
>>> 153: // Our executable name (should not be quoted)
>>
>> ok here, because the full path is being explicitly passed to CreateProcess.
>> If the command line is to be parsed and the executable path contains a space, CreateProcess does say it should be quoted. It would be good to have a test case with a space in the executable path.
>
> Indeed, this seems sus. I need to dig more into this. I recall initially quoting all arguments and then running into problems with the executable. Maybe it is that spaces needs to be quoted, but not other special characters. I'll check what you are doing in ProcessImpl.java and see if I can align my code to do the same.
Passing arguments on Windows is tricky. We faced a similar challenge implementing shims in the Windows JDK installer. See [JDK-8266473](https://bugs.openjdk.org/browse/JDK-8266473), [JDK-8296383](https://bugs.openjdk.org/browse/JDK-8296383), and [JDK-8309489](https://bugs.openjdk.org/browse/JDK-8309489). All three CRs about the same issue until we finally fixed it properly.
You need to encode command line args in a string suitable for passing to `CreateProcess()` function. The decoding algorithm is described at https://learn.microsoft.com/en-us/cpp/c-language/parsing-c-command-line-arguments?view=msvc-170&redirectedfrom=MSDN. You need to implement the reverse algorithm. It is not officially documented at MSDN. Fortunately, somebody contributed it to the blog post at https://learn.microsoft.com/en-us/archive/blogs/twistylittlepassagesallalike/everyone-quotes-command-line-arguments-the-wrong-way.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24380#discussion_r2355902250
More information about the core-libs-dev
mailing list