jexec uses argv[0] parameter to find its own location[1]. argv[0] is populated with the command value causing a failure to locate java[2] when jexec is found in the PATH (in this case argv[0] contains just 'jexec').
We can use /proc/self/exe to locate the executable path on Linux.
The code already contains Linux-specific defines[3], and the use-case is specific to Linux. I am proposing to limit the fix only to the Linux platform.
Note: I am happy to work on this issue.
[1] https://github.com/openjdk/jdk/blob/0c3bc71d24fa13a0b1e55541c01554cd5e124027/src/java.base/unix/native/launcher/jexec.c#L169
[2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1029342
[3] https://github.com/openjdk/jdk/blob/0c3bc71d24fa13a0b1e55541c01554cd5e124027/src/java.base/unix/native/launcher/jexec.c#L184C1-L185C1
We can use /proc/self/exe to locate the executable path on Linux.
The code already contains Linux-specific defines[3], and the use-case is specific to Linux. I am proposing to limit the fix only to the Linux platform.
Note: I am happy to work on this issue.
[1] https://github.com/openjdk/jdk/blob/0c3bc71d24fa13a0b1e55541c01554cd5e124027/src/java.base/unix/native/launcher/jexec.c#L169
[2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1029342
[3] https://github.com/openjdk/jdk/blob/0c3bc71d24fa13a0b1e55541c01554cd5e124027/src/java.base/unix/native/launcher/jexec.c#L184C1-L185C1