On Tue, 9 Sep 2025 13:15:57 GMT, Magnus Ihse Bursie <[email protected]> wrote:
>> In the static JDK image, a single humongous java executable is generated,
>> and no other launcher, such as javac. This makes it impossible to run our
>> jtreg tests, which assume these are present.
>>
>> The solution is fortunately simply: we just need to add a bunch of trivial
>> launchers, which are thin wrappers that execute the main java binary, with
>> the proper arguments. This will result in the same behavior as the normal
>> dynamic launchers, only that we will need to take the detour of launching
>> another process instead of calling directly into the JLI library.
>
> Magnus Ihse Bursie has updated the pull request incrementally with one
> additional commit since the last revision:
>
> Update based on review
src/java.base/share/native/launcher/main.c line 41:
> 39:
> 40: // This is reported when requesting a full version
> 41: static char* launcher = LAUNCHER_NAME;
Is it guaranteed that `LAUNCHER_NAME` is always defined at build time? Is it
safer to keep the `ifdef LAUNCHER_NAME` check and initialize `launcer` to
`NULL` if `LAUNCHER_NAME` is not defined? From removed defines.h:
#ifdef LAUNCHER_NAME
static const char* const_launcher = LAUNCHER_NAME;
#else /* LAUNCHER_NAME */
static char* const_launcher = NULL;
#endif /* LAUNCHER_NAME */
src/java.base/share/native/launcher/main.c line 44:
> 42:
> 43: // This is used as the name of the executable in the help message
> 44: static char* progname = PROGNAME;
Same question for `PROGNAME` as the one for `LAUNCHER_NAME` above.
src/java.base/share/native/launcher/main.c line 61:
> 59: cpwildcard = JNI_FALSE;
> 60: }
> 61: if (strncmp(arg, "-J-DjavaLauncherProgname=", 26) == 0) {
It's better to replace the hardcoded string length with `strlen()` or
`JLI_StrLen()`, e.g.:
const char *progname_prefix = "-J-DjavaLauncherProgname=";
int progname_prefix_len = strlen(progname_prefix);
if (strncmp(arg, "-J-DjavaLauncherProgname=", progname_prefix_len) == 0) {
progname = arg + progname_prefix_len;
...
src/java.base/windows/native/launcher/relauncher.c line 1:
> 1: /*
How did you test the relauncher for Windows? Can you remind me if static JDK is
support for Windows?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24380#discussion_r2338153342
PR Review Comment: https://git.openjdk.org/jdk/pull/24380#discussion_r2338163122
PR Review Comment: https://git.openjdk.org/jdk/pull/24380#discussion_r2338170678
PR Review Comment: https://git.openjdk.org/jdk/pull/24380#discussion_r2338210218