On Sun, 29 Sep 2024 17:44:30 GMT, Attila Szegedi <att...@openjdk.org> wrote:
> Fixes a regression with #17818 where `ArrayList.subList(…).sort()` started > incrementing `ArrayList.modCount` resulting in some cases throwing a > `ConcurrentModificationException` where none was thrown before. > > This change keeps the optimization from #17818 but restores the behavior > where only sorting the `ArrayList` changes the mod count, but sorting its > sublists does not. I am not a spcialist here. But if sorting the parent list is considered as a modification, and if the sublist is just a view of the parent list, then surely sorting/modifying the sublist should be considered as a modification of the parent list? In which case the issue here is probably deeper: SubList and parent list appear to maintain separate `modcount` variables which are only loosely coupled. Maybe that's the bug that ought to be fixed? ------------- PR Comment: https://git.openjdk.org/jdk/pull/21250#issuecomment-2383407392