RFR: 8346719: Add relaunchers to the static JDK image for missing executables [v9]
Magnus Ihse Bursie
ihse at openjdk.org
Wed Sep 17 19:06:50 UTC 2025
On Wed, 17 Sep 2025 15:23:47 GMT, Alexey Semenyuk <asemenyuk at openjdk.org> wrote:
>> 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.
Yes, I've read that blog post, tried to implement it and credited in the source code. :-)
The discussion was if the executable name should be treated differently than the command line arguments. I've added code do explicitly do this, but I don't any longer recall why (this was originally developed back in like May or April, it's just been sitting on the shelf waiting for me to get to the finish line). I do recall that I ran into problems when I treated the executable name as any other argument though, so *something* special needs to be done about it.
But reading this blog post again, it seems that it claims that the program name should be quoted the same way as well. I'll try to go back in time and check my notes, command line histories and old commits to see if I can figure out what kind of issue I ran into. Otherwise the correct solution seem to be to quote the program name the same way.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24380#discussion_r2356490736
More information about the core-libs-dev
mailing list