RFR: 7902847: Class directory of a test case should be always used to compile a library [v3]

Leonid Mesnik lmesnik at openjdk.org
Wed Mar 26 15:43:28 UTC 2025


On Wed, 26 Mar 2025 15:08:27 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

> Hello Leonid,
> 
> Not a code review, but a general review about the proposal.
> 
> > The only reliable fix would be don't use shared class directory at all and compile all libraries for each test.
> 
> By all libraries, do you mean all classes that reside under the directory tree of each of the `@library` that been declared on a specific test definition?
> 
Yes,

> > Although it looks like huge performance overhead, the impact is low.
> 
> The before/after numbers that you posted for the JDK repo look reasonable. JDK isn't the sole user of `jtreg`, but yes I think it's the largest user, so we might have to consider if this change needs to be configurable in some way to allow select projects (like the JDK) to opt-in to this new behaviour.
> 
Hmm, just curious, what are the other users.
> > The libraries are not often compiled using build tag.
> 
> I have a contradicting understanding of that. In fact, the jtreg documentation here https://openjdk.org/jtreg/tag-spec.html for `@library` tag strongly recommends using `@build` for library classes used in the test:
> 
> > In general, classes in library directories are not automatically compiled as part of a compilation command explicitly naming the source files containing those classes. A test that relies upon library classes should contain appropriate @build directives to ensure that the classes will be compiled. It is strongly recommended that tests do not rely on the use of implicit compilation by the Java compiler. Such an approach is generally fragile, and may lead to incomplete recompilation when a test or library code has been modified.

This part of documentation needs to be updated. The main issues is that requirement to use `@build` directive for each package or class used from library by test is overkill. Engineers prefer to rely on implicit compilation. So we have thousands of implicit usage of libraries in our tests. The explicit build is used usually only if test source doesn't depend on the library classes during compilation. Usually, if they are used by classes running with ProcessTools. 

Might be all would work if jtreg disable implicit compilation library dependency and require to cover all classes by build but it overcomplicate tests.

Yes, it is a known and existing problem that "implicit" dependency doesn't call recompilation if library changes only. However, nothing can be done with it right now.

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

PR Comment: https://git.openjdk.org/jtreg/pull/256#issuecomment-2754875577


More information about the jtreg-dev mailing list