----- Mail original ----- > De: "Stuart Marks" <stuart.ma...@oracle.com> > À: "core-libs-dev" <core-libs-dev@openjdk.java.net> > Envoyé: Vendredi 16 Avril 2021 19:40:55 > Objet: ReversibleCollection proposal
> This is a proposal to add a ReversibleCollection interface to the Collections > Framework. I'm looking for comments on overall design before I work on > detailed > specifications and tests. Please send such comments as replies on this email > thread. > > Here's a link to a draft PR that contains the code diffs. It's prototype > quality, > but it should be good enough to build and try out: > > https://github.com/openjdk/jdk/pull/3533 > > And here's a link to a class diagram showing the proposed additions: > > > https://cr.openjdk.java.net/~smarks/ReversibleCollection/ReversibleCollectionDiagram.pdf > > Thanks, > > s'marks Thinking a little bit about your proposal, introducing an interface right in the middle of a hierarchy is not a backward compatible change (you have an issue when the compiler has to use the lowest upper bound). By example void m(List<Collection<String>> list) { ... } var list = List.of(new LinkedHashSet<String>(), List.of("foo")); m(list); // does not compile anymore currently the type of list is List<Collection<String>> but with your proposal, the type will be List<ReversibleCollection<String>> Rémi