-
Bug
-
Resolution: Fixed
-
P2
-
None
-
b19
-
Verified
After JDK-8325679 (Optimize ArrayList subList sort), sequentially creating two sublists from an arraylist and then sorting both of them fails with a CME.
The review forJDK-8325679 mentions 'this doesn't change observable behaviour'. Since it appears to have changed observable behaviour, could this be backed out, and re-done with a CSR if the behaviour change ends up being necessary?
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;
class T {
public static void main(String[] args) {
List<Integer> l = new ArrayList<>(List.of(1, 2, 3, 4));
var a = l.subList(0, 2);
var b = l.subList(2, 4);
Collections.sort(a);
Collections.sort(b);
System.err.println(l);
}
}
With openjdk full version "24-ea+13-1421"
java T.java
[1, 2, 3, 4]
With openjdk full version "24-ea+14-1523"
Exception in thread "main" java.util.ConcurrentModificationException
at java.base/java.util.ArrayList$SubList.checkForComodification(ArrayList.java:1498)
at java.base/java.util.ArrayList$SubList.sort(ArrayList.java:1588)
at java.base/java.util.Collections.sort(Collections.java:145)
at T.main(T.java:10)
The review for
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;
class T {
public static void main(String[] args) {
List<Integer> l = new ArrayList<>(List.of(1, 2, 3, 4));
var a = l.subList(0, 2);
var b = l.subList(2, 4);
Collections.sort(a);
Collections.sort(b);
System.err.println(l);
}
}
With openjdk full version "24-ea+13-1421"
java T.java
[1, 2, 3, 4]
With openjdk full version "24-ea+14-1523"
Exception in thread "main" java.util.ConcurrentModificationException
at java.base/java.util.ArrayList$SubList.checkForComodification(ArrayList.java:1498)
at java.base/java.util.ArrayList$SubList.sort(ArrayList.java:1588)
at java.base/java.util.Collections.sort(Collections.java:145)
at T.main(T.java:10)
- relates to
-
JDK-8079444 ArrayList updates modCount on sorting, which break compatibility
-
- Closed
-
-
JDK-8203704 remove increment of modCount from ArrayList and Vector replaceAll()
-
- Draft
-
-
JDK-8325679 Optimize ArrayList subList sort
-
- Resolved
-
- links to
-
Commit(master) openjdk/jdk/260d4658
-
Review(master) openjdk/jdk/21250