RFR: 8340380: Improve source launcher's shebang script detection [v3]
Jaikiran Pai
jpai at openjdk.org
Fri Jan 10 16:09:42 UTC 2025
On Thu, 9 Jan 2025 09:20:51 GMT, Christian Stein <cstein at openjdk.org> wrote:
>> Please review this change that improves the launcher mode detection by reading the initial two characters from the started file for being a shebang script. It addresses the reported confusing error messages and also supports more shebang line variations. Including those line variations that omit the `--source` arguments like shown in the underlying issue description of JDK-8340380.
>>
>> Tests of tier 1..3: _in progress_
>
> Christian Stein has updated the pull request incrementally with one additional commit since the last revision:
>
> Flip initial checks to restore original behaviour
>
> Avoid regression encoded in `test/jdk/tools/launcher/SourceMode.testClassNamedJava()` assertions
src/java.base/share/native/libjli/java.c line 763:
> 761: if (stat(arg, &st) != 0)
> 762: return JNI_FALSE;
> 763: if (JLI_HasSuffix(arg, ".java") == JNI_TRUE)
Hello Christian, I think it might be better to retain the previous order and first check for the suffix and if it's not `.java`, only then do a `stat` system call.
Also a nit - the `== JNI_TRUE` isn't needed, just `if (JLI_HasSuffix(arg, ".java"))` would be enough.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21910#discussion_r1910589659
More information about the core-libs-dev
mailing list