-
Enhancement
-
Resolution: Fixed
-
P4
-
23
-
b05
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8331913 | 21.0.5-oracle | Mimoun Ghordou | P4 | Resolved | Fixed | b01 |
JDK-8332804 | 21.0.4 | Martin Doerr | P4 | Resolved | Fixed | b05 |
A lot of our tests use a multi-step recipe to spawn and wait for a process. Here's an example
```
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
"-XX:-UseTLAB",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+VerifyDuringStartup",
"-Xlog:gc+verify=debug",
"-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
... do something with output and wait for the process to complete ...
```
These are the steps involved:
1) Create a `ProcessBuilder`
2) Call `ProcessBuilder::start`
3) Create an `OutputAnalyzer`
4) Perform an operation that finally waits for the process to, at least partially, complete (OutputAnalyzer::getOutput, OutputAnalyzer::shouldHaveExitValue(), and more).
Almost all our tests could be converted to use a single call to `ProcessTools.executeTestJava` (or `executeLimitedTestJava`), which spawns the process, makes sure that it has fully completed, and then returns a filled-in OutputAnalyzer to the caller. The above example would become:
```
OutputAnalyzer output = ProcessTools.executeTestJava(
"-XX:-UseTLAB",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+VerifyDuringStartup",
"-Xlog:gc+verify=debug",
"-version");
```
I propose that we make this change in the GC tests, to make our code simpler and hopefully easier to read.
```
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
"-XX:-UseTLAB",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+VerifyDuringStartup",
"-Xlog:gc+verify=debug",
"-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
... do something with output and wait for the process to complete ...
```
These are the steps involved:
1) Create a `ProcessBuilder`
2) Call `ProcessBuilder::start`
3) Create an `OutputAnalyzer`
4) Perform an operation that finally waits for the process to, at least partially, complete (OutputAnalyzer::getOutput, OutputAnalyzer::shouldHaveExitValue(), and more).
Almost all our tests could be converted to use a single call to `ProcessTools.executeTestJava` (or `executeLimitedTestJava`), which spawns the process, makes sure that it has fully completed, and then returns a filled-in OutputAnalyzer to the caller. The above example would become:
```
OutputAnalyzer output = ProcessTools.executeTestJava(
"-XX:-UseTLAB",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+VerifyDuringStartup",
"-Xlog:gc+verify=debug",
"-version");
```
I propose that we make this change in the GC tests, to make our code simpler and hopefully easier to read.
- backported by
-
JDK-8331913 Update GC tests to use execute[Limited]TestJava
- Resolved
-
JDK-8332804 Update GC tests to use execute[Limited]TestJava
- Resolved
- links to
-
Commit openjdk/jdk21u-dev/9035981e
-
Commit openjdk/jdk/1d1cd32b
-
Review openjdk/jdk21u-dev/594
-
Review openjdk/jdk/17067
(1 links to)