RFR: 8334433: jshell.exe runs an executable test.exe on startup

Jan Lahoda jlahoda at openjdk.org
Tue Jun 25 12:00:11 UTC 2024


On Sun, 23 Jun 2024 04:20:18 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

>> test/langtools/jdk/jshell/TerminalNoExecTest.java line 68:
>> 
>>> 66:                 System.exit(1);
>>> 67:             }
>>> 68:             System.exit(0);
>> 
>> Hello Jan, calling `System.exit()` from within the jtreg test isn't recommended as noted in https://openjdk.org/jtreg/faq.html#should-a-test-call-the-system.exit-method. Just throwing a exception should fail the test here - something like `throw new AssertionError("jshell unexpectedly spawned a new process");`
>
> Please ignore my previous comment. I now see what's being done here - although this is a jtreg test class, the test itself launches this class as a main application through `ProcessBuilder` and it's only in that flow that the `System.exit(...)` gets called. I think that is fine.

FWIW, the reason to start another process is that we need (more) control over the stdin/stdout here, which is not (I think) possible using jtreg. Hence we fork a new process, that performs the real test. The test is still somewhat fragile.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/19828#discussion_r1652668354


More information about the kulla-dev mailing list