[jdk21u-dev] RFR: 8334433: jshell.exe runs an executable test.exe on startup
Taizo Kurashige
tkurashige at openjdk.org
Mon Oct 20 10:43:47 UTC 2025
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.
-------------
Commit messages:
- Merge branch 'openjdk:master' into jshell_test_exe_bug
- Add empty check for commands
- Fix to ignore tty
- Merge branch 'openjdk:master' into jshell_test_exe_bug
- Fix indent and space
- Merge branch 'openjdk:master' into jshell_test_exe_bug
- Fix to get Cygwin/MSYS root path
- Revert "Fix to check whether unexpected is included"
- Fix to execute isWindowsSystemStream() on posix
- Fix to check whether unexpected is included
- ... and 9 more: https://git.openjdk.org/jdk21u-dev/compare/38baaa91...44b90e04
Changes: https://git.openjdk.org/jdk21u-dev/pull/2362/files
Webrev: https://webrevs.openjdk.org/?repo=jdk21u-dev&pr=2362&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8334433
Stats: 226 lines in 4 files changed: 224 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/jdk21u-dev/pull/2362.diff
Fetch: git fetch https://git.openjdk.org/jdk21u-dev.git pull/2362/head:pull/2362
PR: https://git.openjdk.org/jdk21u-dev/pull/2362
More information about the jdk-updates-dev
mailing list