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 2 commits intoopenjdk:lworldfrom
Conversation
|
👋 Welcome back bhuang! A progress list of the required criteria for merging this PR into |
|
@bwhuang-us This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 18 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@liach) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
| } | ||
| } | ||
|
|
||
| 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?
There was a problem hiding this comment.
This comment is for the repeated call on hashCode() below. It doesn't specifically demonstrate anything about identity hash behavior. I will reword it to "Repeated calls should produce the same array hash code"
| 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);
}
There was a problem hiding this comment.
I will change the Point record to a class, as value classes fall back to Object.hashCode() which is computed via System.identityHashCode(), per JEP 401.
| 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.
There was a problem hiding this comment.
Are you suggesting to completely remove the assertion message or keep the "setAll" and "parallelSetAll" cases to indicate the operations?
There was a problem hiding this comment.
You can keep setAll/parallelSetAll. Even though they can be deduced from line numbers, that is not quite straightforward.
JUnit when reporting the failure already includes the name argument passed for ParameterizedTest, or you can make the @ParameterizedTest(name = "{0}") so it substitutes the name arg in its parameterized name.
Webrevs
|
liach
left a comment
There was a problem hiding this comment.
Lgtm, the error message beautification is trivial.
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
Reviewers
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