[jdk21u-dev] RFR: 8334433: jshell.exe runs an executable test.exe on startup
Taizo Kurashige
tkurashige at openjdk.org
Thu Oct 30 00:57:08 UTC 2025
On Mon, 20 Oct 2025 10:37:14 GMT, Taizo Kurashige <tkurashige at openjdk.org> wrote:
> This is a backport of JDK-8334433 : jshell.exe runs an executable test.exe on startup
>
> This bug began occurring in jdk21 due to the backport of [JDK-8327476](https://bugs.openjdk.org/browse/JDK-8327476) (it likely also occurs in 17 and 11).
>
> Original patch does not apply cleanly, there are the following differences:
>
> ・ExecTerminalProvider.java
> Because of the presence of `FfmTerminalProvider` in the original patch, `isPosixSystemStream` is not executed on Windows, so test.exe is not executed. However, in jdk21, there is no `FfmTerminalProvider`, so `isPosixSystemStream` is executed and if the `PATH` contains the path of the directory containing unintended test.exe, this test.exe will be executed. To avoid this, I fixed to execute just `isWindowsSystemStream` on Windows (not including Cygwin and MSYS).
>
> ・OSUtils.java
> The original patch hardcoded the paths where test command is located in the Posix environment, but these paths are virtual, so if you are using Cygwin or MSYS, you must specify a Windows path (Usually C:\cygwin64\bin or C:\msys64\usr\bin), otherwise `isExecutable` will not be true, and eventually `isPosixSystemStream` will not be able to execute the intended test.exe. To solve this problem, Cygwin or MSYS uses `cygpath` to specify the actual path on Windows. (In the original fix, `isPosixSystemStream` is not executed on Cygwin or MSYS, so this does not matter.)
>
> ・ConsoleIOContext.java
> Since there is no `FfmTerminalProvider` in jdk21, the original fix is not applicable. Therefore, no fix was made for ConsoleIOContext.java.
>
> ・TerminalNoExecTest.java
> The original fix confirms that no processes are created, but since there is no `FfmTerminalProvider` in jdk21, the test command is executed.
> In jdk21, this fix causes the intended test command to run. Therefore, I created a test `TerminalExecTest.sh
> ` and `TerminalExecTest.java` to verify that the intended executable `test` was executed. (The reason for creating TerminalExecTest.sh is commented within it. To put it simply, I created it due to environmental variable considerations.)
>
> Testing:
> ・test/jdk/jdk/internal/jline, :langtools_jshell and test/jdk/sun/tools/jhsdb/JShellHeapDumpTest.java on RHEL9.4 and Windows Server 2022(Cygwin and MSYS), GHA testing
> ・I manually verified that the problem described in [JDK-8334433](https://bugs.openjdk.org/browse/JDK-8334433)'s Description does not reproduce in Windows Command Prompt.
>
> Thanks.
Could anyoen revew this PR?
-------------
PR Comment: https://git.openjdk.org/jdk21u-dev/pull/2362#issuecomment-3465721535
More information about the jdk-updates-dev
mailing list