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

Jaikiran Pai jpai at openjdk.org
Tue Jun 25 14:10:19 UTC 2024


On Tue, 25 Jun 2024 11:57:08 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

>> 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.

Launching of a new `java` application from within the jtreg test is fine and is done in several places. What confused me was that the test was launching the test class itself as an application. I don't know if it's a convention, but I usually have a separate nested `public class FooBarWhatever`  within the test class which I launch using the ProcessBuilder as `Test$FooBarWhatever` and have the application logic reside in the main() method of `FooBarWhatever`. 

I am not expecting that you change the PR to do it that way though. Once I spent a few seconds on that code, it was clear what it was doing.

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

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


More information about the kulla-dev mailing list