RFR: 8354766: Test TestUnexported.java javac build fails

Jaikiran Pai jpai at openjdk.org
Thu Apr 17 10:57:45 UTC 2025


On Wed, 16 Apr 2025 04:03:24 GMT, SendaoYan <syan at openjdk.org> wrote:

> Hi all,
> 
> The newly added test jdk/javadoc/doclet/testUnexported/TestUnexported.java javac build fails. This PR add depedencies to make javac build success. Test-fix only, change has been verified locally, no risk.

Marked as reviewed by jpai (Reviewer).

I spoke to Nizar and also looked at the linked JBS issue. What's happening here is that this test uses a test library `/tools/lib` and one of the classes `JavacTask` in the test library references an internal API `com.sun.tools.javac.api.JavacTool`. Depending on which test triggers the usage of this `JavacTask`, it can so happen that this test library class will get compiled with a different set of compilation options. I believe (and we experimented locally too), on our CI setup where we launch several tests, this test library `JavacTask` gets compiled when running a test which has the right set of compilation options (including the necessary `--add-exports`). Thus when this `TestUnexported` test gets run later, jtreg finds that the test library class `JavacTask` is already compiled and available in the one of the classpath directories of this test class. So it doesn't trigger a compilation of `JavacTask` and instead reuses the already compiled on. Thus we don't see this failure in t
 hose situations.

On setups where this is failing, including when you explicitly launch only the TestUnexported test (`make test TEST=test/langtools/jdk/javadoc/doclet/testUnexported/TestUnexported.java`), the test library class `JavacTask` hasn't already been compiled and thus jtreg triggers compilation of that class and since this specific test doesn't use a `@modules` for exporting those internal packages, the compilation command doesn't add the explicit `--add-exports` and thus the compilation fails for the test library `JavacTask` class.

The non-deterministic compilation of test library classes is a known issue in jtreg. The proposed fix in this PR to get past this issue is the right solution for now.

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

PR Review: https://git.openjdk.org/jdk/pull/24673#pullrequestreview-2775349147
PR Comment: https://git.openjdk.org/jdk/pull/24673#issuecomment-2812496384


More information about the javadoc-dev mailing list