RFR: 8356974: tools/launcher/ToolsOpts.java fails if the build id contains "-J"

Manuel Hässig mhaessig at openjdk.org
Wed May 14 14:45:04 UTC 2025


When passing `-J-version` to the patched javac, `tools/launcher/ToolsOpts.java` wants to verify that the output corresponds to the expected version output. However, if the build id of the JDK running this test contains the substring "-J", then the test fails incorrectly at:

https://github.com/openjdk/jdk/blob/97b0dd2167530b3d237e748cd5da0130e38e8af2/test/jdk/tools/launcher/ToolsOpts.java#L131-L134

This PR addresses this false positive by looking for the substring `" -J-"` instead. The preceding space to ensure that `-J` occurs at the beginning of a word as an argument would and a `-` suffix since `-J` options are always followed by a dash. Further, this PR adds a print of the output of the test result in case this condition fails, to be able to inspect what triggered the failure.

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

Commit messages:
 - Add output to ease debugging, if the test fails
 - Fix test by searching for the beginning of a word

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

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


More information about the core-libs-dev mailing list