[External] : Re: New candidate JEP: 431: Sequenced Collections

Stuart Marks stuart.marks at oracle.com
Sat Oct 15 22:25:18 UTC 2022


Hi Rémi,

On 10/14/22 1:20 AM, Remi Forax wrote:
> People will again think that i'm the grumpy guy but i prefer to voice my concerns.
> 
> - nobody cares, i'm back from Devoxx and nobody cares about Sequenced Collections, i've tried to ask several friends what they think about it and the answer was "meh".
>    The bar to introduce new interfaces in the collection API is really really high given how the Java ecosystem works.
>    Once a library starts to use those interfaces as method parameter, it pressures the other library authors to write methods that provides object typed as those interfaces.
>    Not enough people care and the cost for the community (not only Oracle) is high, it looks like a recipe for failure.

Fortunately, we don't make decisions in OpenJDK via opinion polls. :-)

I'm obviously not in a position to address the concerns of your interlocutors. 
However, the history in the bug database and the recurring discussions on 
core-libs-dev (some of which are linked in the JEP) show the need for this.

Introduction of new types always poses a dilemma for library maintainers. They can 
move forward aggressively and embrace new features, or they can remain on older 
releases in order to reach a broader audience. That's not a reason to avoid 
introducing new types.

> - LinkedHashMap can be tweaked in two ways, by passing an access order as 3rd parameter of the constructor or by overriding removeEldesEntry(), in both cases the resulting LinkedHashMap is at odds with the contract of SequencedMap but the compiler will happily allow to see those LinkedHashMap as SequencedMap.

SequencedMap specifies that entries have an encounter order but it doesn't make any 
requirements on how that order is established. LinkedHashMap's access-order mode is 
unusual in that it specifies that specific methods additionally have the side effect 
of reordering the relevant entry. The removeEldestEntry() method modifies the 
behavior of mapping-insertion methods to optionally remove the first ("eldest") 
entry. Neither of these behaviors conflicts with anything in SequencedMap.

> - LinkedHashMap/LinkedHashSet are dinosaurs, there are more efficient implementations of the concepts of ordered set / ordered map both in term of memory footprint and runtime execution, so adding new interfaces without exploring new implementations using Valhalla value class and in relation with the Collection Literal JEP seems premature to me.

LinkedHashMap and LinkedHashSet are in fact used fairly frequently. They're not used 
as much as HashMap, but they're used more than ArrayDeque or TreeMap. Presumably 
this is because people find LinkedHashMap/Set useful and that the overhead compared 
to their non-linked counterparts is acceptable for the additional services they provide.

The performance and footprint of LinkedHashMap/Set are not impacted either way by 
the JEP, nor are any potential future performance improvements (including those that 
might arise because of Valhalla) precluded by the JEP.

s'marks



More information about the core-libs-dev mailing list