[jdk8u-dev] RFR: 8327993: [8u] Unify test libraries into single test library - step 2
Zdenek Zambersky
zzambers at openjdk.org
Tue Mar 12 15:30:58 UTC 2024
This is second step in the effort to unify duplicate test libraries in jdk8 into single shared test library (as in newer jdks). Motivation is to remove code duplication and make backporting simpler. It only affects tests. More details in [step 1](https://github.com/openjdk/jdk8u-dev/pull/294).
This changeset eliminates duplicate test lib in hotspot ( `hotspot/test/testlibrary` ) by unifying it with shared test library ( `test/lib` ). Hotspot tests have been updated to use (unified) shared test library.
**DETAILS:**
Unification of test libraries was done on per file basis, comparing (diff) classes from both libraries and deciding on approach used. (Generally, files in shared test lib (originally coming from jfr backport) are more updated. However there were some compatibility problems with jdk8 in some places.)
- Legend:
- kept - kept existing file in shared test library as is
- same - files in both libraries (hotspot, shared) are effectively same (copyright/package differences etc.)
- superset - file in shared test library is superset (in terms of API) of hotspot one
- testlib **packageless** (test/lib)
- **`ClassFileInstaller.java`** - kept (same)
- **`RedefineClassHelper.java`** - used updated one from hs test lib (was missing in shared lib)
- testlib **general** (test/lib/jdk/test/lib)
- **`Asserts.java`** - kept (superset)
- **`BuildHelper.java`** - kept (same)
- **`ByteCodeLoader.java`** - kept (superset)
- **`JDKToolFinder.java`** - kept (same)
- **`JDKToolLauncher.java`** - kept, with reverted [changes from JDK-8178415](https://github.com/openjdk/jdk11u-dev/commit/05d6891929153c34d101c05a7e04185ebbd05849) to match one from hs test lib (otherwise no real differences)
- **`Platform.java`** - kept shared version (superset), with some fixes. Updated debug build detection code as jdk8 does not have `jdk.debug` system property. Removed `areCustomLoadersSupportedForCDS` as this is only useful for appcds tests (not in jdk8)
- **`Utils.java`** - kept, added missing `getUnsafe()` method, required by hotspot tests
- testlib **cli** (test/lib/jdk/test/lib/cli)
- only used by hotspot tests, classes in shared test lib were unused so far
- used updated files from hotspot test lib, as shared version contained [incompatible changes from JDK-8054892](https://github.com/zzambers/jdk11u-dev/commit/29f7c15af9c8b8199765186c188e9a280f559766) (not backported to jdk8) and did not work with hotspot tests
- testlib **compiler** (test/lib/jdk/test/lib/compiler)
- **`InMemoryJavaCompiler.java`** - used updated one from hs test lib (was missing in shared test lib)
- testlib **conainer** (test/lib/jdk/test/lib/container)
- **`Common.java`** - kept (same)
- **`DockerfileConfig.java`** - kept (same)
- **`DockerRunOptions.java`** - kept, added missing [changes from JDK-8229182](https://github.com/openjdk/jdk8u-dev/commit/c5751e60a8f2a9e5f959b1fbc7fb2d91cd20ece4)
- **`DockerTestUtils.java`** - kept, added missing [changes from JDK-8229182](https://github.com/openjdk/jdk8u-dev/commit/c5751e60a8f2a9e5f959b1fbc7fb2d91cd20ece4)
- testlib **management** (test/lib/jdk/test/lib/management)
- **`DynamicVMOption.java`** - kept (same)
- testlib **process** (test/lib/jdk/test/lib/process)
- **`ExitCode.java`** - kept (same)
- **`OutputAnalyzer.java`** - kept (superset)
- **`OutputBuffer.java`** - kept (same)
- **`ProcessTools.java`** - kept, with added getPlatformSpecificVMArgs (effectively reverted [changes from JDK-8178415](https://github.com/openjdk/jdk11u-dev/commit/05d6891929153c34d101c05a7e04185ebbd05849)), updated getProcessId (better to throw on error, kept it returning long (as on newer jdks)), removed pid() method from ProcessImpl (not necessary, Process in jdk8 does not have pid method)
- **`StreamPumper.java`** - kept (superset)
- **whitebox** (test/lib/sun/hotspot)
- **`Whitebox.java`** - went through differences, removed functions not implemented in hotspot from shared lib. (Also fixed few calls in shared lib, wrongly expecting [changes from JDK-8171008](https://github.com/openjdk/jdk11u-dev/commit/2c220df590f2de212d1fc227b8264cf525be2bcc#diff-e75d116b35afd951f114c2b0793b26d0009b441653d6b28d611afcbe0106dfd0) in jdk8). Result is close to one from hs testlibrary, some wrapper functions around low level functions kept (used in code).
- **`Nmethod.java`** - used updated file from hs test lib, lack of hotspot support (shared lib version expected `wb.getNMethod` to return data in new format - not in jdk8)
- **`CodeBlob.java`** - kept, removed getCodeBlobs method (jdk8 hotspot lacks support for WB.getCodeHeapEntries)
- **`CPUInfo.java`** - kept (same)
- **`DiagnosticCommand.java`** - used updated file from hs test lib (jdk8u is missing changes by [JDK-8065783](https://bugs.openjdk.org/browse/JDK-8065783) expected by shared lib version)
- **`GC.java`** - removed - unused and (hotspot) support for this is missing in jdk8 (see [JDK-8154096](https://bugs.openjdk.org/browse/JDK-8154096))
- testlibrary **other**
- **`PerfCounter.java`** - moved/updated to `hotspot/test/gc/testlibrary ` [corresponding to newer jdks](https://github.com/openjdk/jdk11u-dev/blob/f3069d13d23301405b096db6d4843500a5f5fa56/test/hotspot/jtreg/gc/testlibrary/PerfCounter.java)
- **`PerfCounters.java`** - moved/updated to `hotspot/test/gc/testlibrary` as in newer jdks
- **`InputArguments.java`** - moved/updated to `hotspot/test/gc/metaspace` as in newer jdks (see [changes by JDK-8157957](https://github.com/openjdk/jdk11u-dev/commit/ad85e18f236a6771a29156535f68ad4c19feb804#diff-aa68303355ebc129db1b43d89fced9af705509fb570e94743e6e88d48f4a784f))
- **ctw** (compile the world, `hotspot/test/testlibrary/ctw`)
- ctw was kept in hotspot's testlibrary, as in newer jdks. Makefile was updated, as necessary.
- **tests**
- imports and `@library` tags were fixed, as necessary
- small fixes to some tests as `ProcessTools.getProcessId()` now returns long (not int). Similar to test modifications [done by JDK-8153992](https://github.com/zzambers/jdk11u-dev/commit/7cf6a15162c794bb200e6e59fc4c81a3cb3cc652) (backport not possible due to ProcessHandle unavailable on jdk8)
- `hotspot/test/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java` was updated, as necessary, to work with Platform class from shared test lib
-------------
Commit messages:
- Unified hs test lib with shared test lib
Changes: https://git.openjdk.org/jdk8u-dev/pull/467/files
Webrev: https://webrevs.openjdk.org/?repo=jdk8u-dev&pr=467&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8327993
Stats: 6173 lines in 477 files changed: 144 ins; 5007 del; 1022 mod
Patch: https://git.openjdk.org/jdk8u-dev/pull/467.diff
Fetch: git fetch https://git.openjdk.org/jdk8u-dev.git pull/467/head:pull/467
PR: https://git.openjdk.org/jdk8u-dev/pull/467
More information about the jdk8u-dev
mailing list