Can I please get a review of this test-only change which addresses the failure 
reported in https://bugs.openjdk.org/browse/JDK-8394341?

This test launches processes as part of its test execution. It was recently 
refactored to use the commonly used JDK internal 
`jdk.test.lib.process.ProcessTools` test library. After this refactoring, 
if/when this test gets launched on a virtual thread (through the 
`-testThreadFactory:Virtual`), then the `testWithClassPathSetViaProperty()` 
test method fails because it launches a `java` processes with a 
custom/controlled classpath.

Given the way `ProcessTools` library is implemented, when launching a `java` 
process in the presence of `-testThreadFactory:Virtual`, the launched process 
is expected to contain the `jdk.test.lib.process.ProcessTools` class in its 
classpath. Given that `testWithClassPathSetViaProperty()`, configures a 
classpath of its own, the test thus fails due to the missing 
`jdk.test.lib.process.ProcessTools`.

In practice, this test shouldn't be run when launching jtreg with 
`-testThreadFactory:Virtual`, neither should the child processes be passed any 
additional arguments than what the test method itself configures. The commit in 
this PR sets up the relevant `@requires` in the test definition to prevent such 
executions. The test methods themselves has been updated to use 
`ProcessTools.executeCommand(...)` to make it clear that the child processes' 
arguments shouldn't be affected by how jtreg is launched (for example, by 
passing `-javaoptions:...`)



---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK 
Interim AI Policy](https://openjdk.org/legal/ai).

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

Commit messages:
 - 8394341: tools/launcher/MiscTests.java fails with ClassNotFoundException: 
jdk.test.lib.process.ProcessTools when test is launched through a virtual thread

Changes: https://git.openjdk.org/jdk/pull/33345/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=33345&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8394341
  Stats: 19 lines in 1 file changed: 16 ins; 0 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/33345.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/33345/head:pull/33345

PR: https://git.openjdk.org/jdk/pull/33345

Reply via email to