ReversibleCollection proposal

Remi Forax forax at
Mon Apr 19 21:01:16 UTC 2021

----- Mail original -----
> De: "Stuart Marks" <stuart.marks at>
> À: "core-libs-dev" <core-libs-dev at>
> 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:
> And here's a link to a class diagram showing the proposed additions:
> 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>>


More information about the core-libs-dev mailing list