https://github.com/openjdk/valhalla/pull/2390 triggered some weird failures and it turned out that this invariant is broken when `ValueClass.newReferenceArray` is called before the default refined klass is created: https://github.com/openjdk/valhalla/blob/7558cd73f557e34b0f11dd0a37952854ab2881f6/src/hotspot/share/oops/objArrayKlass.cpp#L410-L414
In that case, the first entry in the linked list will not be the default refined klass but the not-flat, nullable variant. This leads to the code emitted by `LibraryCallKit::load_default_refined_array_klass` returning the wrong refined klass and thus to wrong results with the `_copyOf` and `_newArray` intrinsics. I added a targeted regression test for this that covers both intrinsics and randomizes the order in which refined klasses are created. The fix was provided by @fparain. Thanks, Tobias --------- - [x] I confirm that I make this contribution in accordance with the [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). ------------- Commit messages: - JDK-8384052 Changes: https://git.openjdk.org/valhalla/pull/2406/files Webrev: https://webrevs.openjdk.org/?repo=valhalla&pr=2406&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8384052 Stats: 182 lines in 4 files changed: 175 ins; 1 del; 6 mod Patch: https://git.openjdk.org/valhalla/pull/2406.diff Fetch: git fetch https://git.openjdk.org/valhalla.git pull/2406/head:pull/2406 PR: https://git.openjdk.org/valhalla/pull/2406
