RFR: 7902847: Class directory of a test case should be always used to compile a library
Leonid Mesnik
lmesnik at openjdk.org
Tue Mar 25 17:52:11 UTC 2025
The classes from test libraries can be compiled implicitly as a test dependency or explicitly with @build tag.
For first case
Test library used as a source path during test compilation and library classes as well as test classes are compiled into class directory.
For 2nd case
The library classes are compiled using @build tag and library classes are placed into some shared location.
These 2 cases might be mixed in the single test and can have part of library classes compiled into shared directory and part compiled into test classes directory.
jtreg uses classfiles to check if source code should be compiled. Let we have 2 classes LibA and Lib that extends LibA.
So if class LibA might be compiled into test class directory while LibB is compiled into library directory. Later jtreg can try to use LibB class without and compilation because LibB already exists. Thus the CNFE will be thrown.
The another possible problem, is that the library code might include test code for libraries like "/" and "/vmTestbase"
so any test classes with same packages would be compiled into the same location because they are treated as library classes. So for tree like this:
test1/Test.java
test2/Test.java
with both tests having
@library "/"
@build Test
we are going just to have one Test class in library directory.
The only reliable fix would be don't use shared class directory at all and compile all libraries for each test. Although it looks like huge performance overhead, the impact is low. The libraries are not often compiled using build tag.
Times for tier1 execution with fix:
test-results/jtreg_test_lib_test_tier1/text/timeStats.txt:Total elapsed time 0m 28s
test-results/jtreg_test_hotspot_jtreg_tier1/text/timeStats.txt:Total elapsed time 18m 14s
test-results/jtreg_test_jdk_tier1/text/timeStats.txt:Total elapsed time 15m 8s
test-results/jtreg_test_langtools_tier1/text/timeStats.txt:Total elapsed time 7m 59s
and before fix
test-results/jtreg_test_lib_test_tier1/text/timeStats.txt:Total elapsed time 0m 32s
test-results/jtreg_test_hotspot_jtreg_tier1/text/timeStats.txt:Total elapsed time 17m 51s
test-results/jtreg_test_jdk_tier1/text/timeStats.txt:Total elapsed time 14m 49s
test-results/jtreg_test_langtools_tier1/text/timeStats.txt:Total elapsed time 7m 56s
The full fix might require more testing and adding testcase.
Please note that there are plans to work on the
https://bugs.openjdk.org/browse/CODETOOLS-7903882
and
https://bugs.openjdk.org/browse/JDK-8346058
So the libraries like '/test/lib' might be precompiled during build without tests and be used as classpath during test execution.
-------------
Commit messages:
- 7902847
Changes: https://git.openjdk.org/jtreg/pull/256/files
Webrev: https://webrevs.openjdk.org/?repo=jtreg&pr=256&range=00
Issue: https://bugs.openjdk.org/browse/CODETOOLS-7902847
Stats: 3 lines in 1 file changed: 0 ins; 0 del; 3 mod
Patch: https://git.openjdk.org/jtreg/pull/256.diff
Fetch: git fetch https://git.openjdk.org/jtreg.git pull/256/head:pull/256
PR: https://git.openjdk.org/jtreg/pull/256
More information about the jtreg-dev
mailing list