RFR: 8356974: tools/launcher/ToolsOpts.java fails if the build id contains "-J"
Jaikiran Pai
jpai at openjdk.org
Mon May 19 08:55:53 UTC 2025
On Wed, 14 May 2025 14:40:41 GMT, Manuel Hässig <mhaessig at openjdk.org> wrote:
> 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.
>
> Testing:
> - [x] [Github Actions](https://github.com/mhaessig/jdk/actions/runs/15023438332)
> - [x] tier1 and tier2 for Oracle supported platforms and OSs plus Oracle internal testing
Hello Manuel,
> 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
The proposed change looks reasonable to me. A brief look through JEP-223 https://openjdk.org/jeps/223 suggests that a space character cannot appear in the JDK version, so this proposed change to use " -J-" won't run into the same issue as previously.
The copyright year on this test will need an update. Please also add a "noreg-self" (https://openjdk.org/guide/#noreg) to the JBS issue.
-------------
PR Review: https://git.openjdk.org/jdk/pull/25230#pullrequestreview-2849969430
More information about the core-libs-dev
mailing list