RFR: 8367598: Switch to CRC32C for SEED calculation in jdk.test.lib.Utils
Weijun Wang
weijun at openjdk.org
Mon Sep 22 15:09:56 UTC 2025
On Mon, 22 Sep 2025 13:26:30 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:
> Can I please get a review of this change to a test library class which proposes to remove the calls to `MessageDigest` from the static initializer of `jdk.test.lib.Utils`?
>
> The `Utils` test library class constructs a random generator which can be used in tests. Back in JDK 16, we updated this class to use a consistent seed (if none is explicitly set) when running against promotable JDK builds. This was done in https://bugs.openjdk.org/browse/JDK-8253750. The motivation behind using a consistent seed as explained in that issue is reasonable.
>
> In the implementation of seed generation, we generate the seed based off the JDK build version and we currently use the `java.security.MessageDigest` class to generate the bytes for the seed. The use of `MessageDigest` here drags in a lot of security-libs infrastructure. If this `Utils` class then gets used in tests that configure the security-libs in a specific manner (like intentionally setting certain configurations which trigger an exception), then the `Utils` class fails during its static initialization. This prevents its usage in such tests as well as sometimes causes unexpected failures like:
>
> https://bugs.openjdk.org/browse/JDK-8367583
> https://bugs.openjdk.org/browse/JDK-8345578
>
> The change in this PR replaces the usage of security-libs infrastructure with a much more simpler implementation for the seed generation. The proposed usage of `CRC32`, to generate the seed based off the version, doesn't drag in these additional classes and should thus prevent issues like the ones noted above.
>
> I've run this change locally as well as our CI (tier1, tier2, tier3) and haven't seen any failures.
Looks good.
I assume there is no need to back out the changes made in JDK-8367583 and JDK-8345578 (at least not here) so that this fix can be backported cleanly if necessary. But you did try that and has confirmed it's no longer an issue, right?
-------------
Marked as reviewed by weijun (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/27427#pullrequestreview-3253411472
More information about the core-libs-dev
mailing list