JDK 21 comes with new SequencedCollection
/SequencedSet
/SequencedMap
types, with SequencedCollection
as super-interface of List
and Deque
, and the other implemented by LinkedHashSet
/LinkedHashMap
. While we won't be able to benefit from the new hierarchy and its new operations in the framework codebase yet, we should provide everything we can for application usage: e.g. detection in CollectionFactory
and support for the new operations in our org.springframework.util
List implementations.
Comment From: jhoeller
CollectionFactory
supports user declarations of type SequencedCollection
/SequencedSet
/SequencedMap
now, e.g. for injection points.
AutoPopulatingList
inherits all SequencedCollection
default methods as declared in the List
interface, automatically supporting them on JDK 21 in a good enough fashion.
For the time being, LinkedCaseInsensitiveMap
and LinkedMultiValueMap
do not implement any SequencedMap
operations since they would have to explicitly implement that interface rather than inherit its declaration. None of those operations seem to matter for the common usage of those classes. If necessary, we can revisit this with extended JDK 21 implementations of LinkedCaseInsensitiveMap
/LinkedMultiValueMap
declaring implements SequencedMap
in our new spring-core
multi-release jar, with the primary feature of a reversed Map view having to be provided (and maintained) then.