Skip to content

8379694: [lworld] Add value class test coverage to java.util.Arrays#2314

Open
bwhuang-us wants to merge 1 commit intoopenjdk:lworldfrom
bwhuang-us:libs-arrays
Open

8379694: [lworld] Add value class test coverage to java.util.Arrays#2314
bwhuang-us wants to merge 1 commit intoopenjdk:lworldfrom
bwhuang-us:libs-arrays

Conversation

@bwhuang-us
Copy link
Copy Markdown
Contributor

@bwhuang-us bwhuang-us commented Apr 9, 2026

Tests Updated

TEST.groups
Add java/util/Arrays to valhalla_adopted, bringing the Arrays test directory into the Valhalla-adopted test group.

AsList.java
Add value-oriented object-array datasets: an @AsValueClass record, boxed Integer, LocalDate, and Optional. This extends the existing iterator contract test to ensure Arrays.asList() behaves the same for value-capable elements, including assertSame on iteration.

ArrayObjectMethods.java
Add an @AsValueClass record and extend the random object/nested-object generators so value objects and value-object arrays participate in the existing toString, deepToString, hashCode, deepHashCode, and deepEquals coverage. This broadens mixed-content object-array coverage rather than adding a separate value-only test path.

ArraysEqCmpTest.java
Add an @AsValueClass Point type and a corresponding ArrayType so the existing Arrays.equals, Arrays.compare, and Arrays.mismatch matrix now runs on value-object arrays too. The object-array same-element tests were also generalized to use the ArrayType abstraction instead of assuming Integer[].

Big.java
Add a large-array Point[] path using an @AsValueClass record. This extends the existing huge-array binarySearch and range-sort coverage to value-object arrays.

CopyMethods.java
Add Point, LocalDate, and Optional to the reflective copy/copyOfRange test matrix, plus the coercion and cloner wiring needed for those types. This extends the existing generic copy-method framework to value-capable reference types.

Correct.java
Add an @AsValueClass Point type plus default-sort and comparator-sort subrange tests for Point[], using the existing “compare against reference sort” approach.

Fill.java
Add an @AsValueClass array target and verify existing exception behavior when filling it with the wrong type or with an out-of-bounds range.

HashCode.java
Add an @AsValueClass Point test that checks Arrays.hashCode(Point[]) is equal for equal value-object arrays and stable across repeated calls.

SetAllTest.java
Add Point[] coverage for Arrays.setAll and Arrays.parallelSetAll, including normal generation cases and the existing null-argument exception checks.

Sorting.java
Add an @AsValueClass Point sort path to the main sorting test suite. This extends the existing object-sort coverage to value objects for both natural ordering and comparator ordering.

StreamAndSpliterator.java
Extend the existing null-array and bad-range exception tests to additional reference-array types: Integer[], Long[], Optional[], and LocalDate[]. This broadens object-array coverage for Arrays.stream, Arrays.spliterator, and Spliterators.spliterator.

largeMemory/ParallelPrefix.java
Add an @AsValueClass VInt type and extend the existing parallelPrefix framework to cover value-object arrays, including normal prefix computation plus NPE/IAE/AIOOBE checks.

Tests With No Change

FloatDoubleOrder.java
No change -- primitive-only float/double ordering test.

SortingIntBenchmarkTestJMH.java, SortingLongBenchmarkTestJMH.java
No change -- primitive-array JMH benchmarks.

SortingNearlySortedPrimitive.java
No change -- primitive-only nearly-sorted coverage.

TimSortStackSize.java, TimSortStackSize2.java
No change -- TimSort stack-shape regression tests over existing Integer[] inputs.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (1 review required, with at least 1 Committer)

Issue

  • JDK-8379694: [lworld] Add value class test coverage to java.util.Arrays (Task - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/valhalla.git pull/2314/head:pull/2314
$ git checkout pull/2314

Update a local copy of the PR:
$ git checkout pull/2314
$ git pull https://git.openjdk.org/valhalla.git pull/2314/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 2314

View PR using the GUI difftool:
$ git pr show -t 2314

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/2314.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper bot commented Apr 9, 2026

👋 Welcome back bhuang! A progress list of the required criteria for merging this PR into lworld will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link
Copy Markdown

openjdk bot commented Apr 9, 2026

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot changed the title JDK-8379694 Add value class test coverage to java.util.Arrays 8379694: Add value class test coverage to java.util.Arrays Apr 9, 2026
@bwhuang-us bwhuang-us changed the title 8379694: Add value class test coverage to java.util.Arrays JDK-8379694 Add value class test coverage to java.util.Arrays Apr 10, 2026
@openjdk openjdk bot changed the title JDK-8379694 Add value class test coverage to java.util.Arrays 8379694: Add value class test coverage to java.util.Arrays Apr 10, 2026
@bwhuang-us bwhuang-us changed the title 8379694: Add value class test coverage to java.util.Arrays 8379694: [lworld] Add value class test coverage to java.util.Arrays Apr 10, 2026
}
}

static void stupidSort(Integer[] a1, int from, int to) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend changing the static types of Integer[] to Comparable[] instead of introducing identical copies of stupid sort. Same for the comparator version, but the comparator version can take Object[]

throw new RuntimeException("testValueClassArrayHashCode: expected equal hash codes " +
"for equal value class arrays, got " + hashA + " and " + hashB);
}
// Consistency with repeated calls (no identity hash interference)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's nothing relevant to identity hash here, dead comment?

public class HashCode {

@AsValueClass
record Point(int x, int y) {}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might consider make its hashCode just return Objects.identityHashCode if preview is enabled for better coverage?
Like:

if (Point.class.isValue()) {
    return Objects.identityHashCode(this);
}

public void testSetAllPoint(String name, int size, IntFunction<Point> generator, Point[] expected) {
Point[] result = new Point[size];
Arrays.setAll(result, generator);
Assertions.assertArrayEquals(expected, result, "setAll(Point[], IntFunction<Point>) case " + name + " failed.");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message is redundant because junit already does it but since this is a copycat guess it's fine.

try {
Arrays.setAll((Point[]) null, (IntFunction<Point>) i -> new Point(i, i));
fail("Arrays.setAll(null, foo) should throw NPE");
} catch (NullPointerException npe) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do assertThrows(NullPointerException.class, () -> ...) instead.

@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 10, 2026
@mlbridge
Copy link
Copy Markdown

mlbridge bot commented Apr 10, 2026

Webrevs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

2 participants