On Tue, 1 Oct 2024 03:18:57 GMT, David Holmes <dhol...@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 agree with just reverting the behaviour as discussed in JBS, but will leave > the actual review for the libs folk. The more general question of when to > trigger CME is a very thorny one. Right, @dholmes-ora, you might recall that we argued about this several years ago. :-) Even though I'm on the losing end of that argument, I am ok with eventually removing the modCount increments from sort and replaceAll. This is covered by JDK-8203704 which should include a spec clarification to support the change in behavior. Meanwhile, this PR should simply revert to the behavior previous to the JDK-8325679 change. (Even though that behavior is arguably wrong.) ------------- PR Comment: https://git.openjdk.org/jdk/pull/21250#issuecomment-2384701569