8379694: [lworld] Add value class test coverage to java.util.Arrays#2314
8379694: [lworld] Add value class test coverage to java.util.Arrays#2314bwhuang-us wants to merge 1 commit intoopenjdk:lworldfrom
Conversation
|
👋 Welcome back bhuang! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
| } | ||
| } | ||
|
|
||
| static void stupidSort(Integer[] a1, int from, int to) { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
There's nothing relevant to identity hash here, dead comment?
| public class HashCode { | ||
|
|
||
| @AsValueClass | ||
| record Point(int x, int y) {} |
There was a problem hiding this comment.
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."); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Let's do assertThrows(NullPointerException.class, () -> ...) instead.
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
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/valhalla.git pull/2314/head:pull/2314$ git checkout pull/2314Update a local copy of the PR:
$ git checkout pull/2314$ git pull https://git.openjdk.org/valhalla.git pull/2314/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 2314View PR using the GUI difftool:
$ git pr show -t 2314Using diff file
Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/2314.diff
Using Webrev
Link to Webrev Comment