RFR: 8314236: Overflow in Collections.rotate [v4]

Nikita Sakharin duke at openjdk.org
Fri Aug 25 13:48:09 UTC 2023


On Thu, 24 Aug 2023 02:36:52 GMT, Stuart Marks <smarks at openjdk.org> wrote:

>> Nikita Sakharin has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8314236: rewrite test
>
> @nikita-sakharin
> 
> Thanks for the updates. With the "Mock List" implementation we can run the test in-JVM and we can avoid allocating several GB of memory. Great!
> 
> The implementation logic in the `rotate1` method looks correct.
> 
> Now that an individual test case is much less expensive, it becomes feasible to add multiple test cases. In particular, for this kind of testing of arithmetic errors, I like to test a variety of edge cases. The one test case you have is for size=`(1 << 30) - 1` and distance=`(1 << 30)`. It would be good to have a few other cases where the existing code fails and where the modified code should pass. I was able to come up with a few examples quickly:
> 
>     size                 distance
>     Integer.MAX_VALUE    2
>     Integer.MAX_VALUE    Integer.MIN_VALUE
>     Integer.MAX_VALUE    Integer.MAX_VALUE - 1
> 
> Please add these cases, and any others that you think might be interesting.

@stuart-marks
Thank you for your review.

Test was failing due to [JDK-8313701](https://bugs.openjdk.org/browse/JDK-8313701). So, I pulled changes from the `master` and squash my commits.

I increased test coverage with respect to your advice. All tests passed successfully.

Awaiting the next step of your review.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/15270#issuecomment-1693385541


More information about the core-libs-dev mailing list