RFC: draft API for JEP 269 Convenience Collection Factories (original) (raw)
Remi Forax forax at univ-mlv.fr
Fri Oct 16 23:17:52 UTC 2015
- Previous message: RFC: draft API for JEP 269 Convenience Collection Factories
- Next message: RFC: draft API for JEP 269 Convenience Collection Factories
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
The other reason I see to avoid methods of on impelmentations is that as i've already said, Java allows to inherits static methods defined on class so adding a method of() on ArrayList will allow people to use of on a subclass of HashMap/ArrayList but did get the expected object, by example, LinkedHashMap.of() will return a HashMap.
so +1 to have methods of() only on interfaces.
Rémi
----- Mail original -----
De: "John Rose" <john.r.rose at oracle.com> À: "Kevin Bourrillion" <kevinb at google.com> Cc: "core-libs-dev" <core-libs-dev at openjdk.java.net> Envoyé: Mercredi 14 Octobre 2015 22:46:40 Objet: Re: RFC: draft API for JEP 269 Convenience Collection Factories
On Oct 14, 2015, at 10:56 AM, Kevin Bourrillion <kevinb at google.com> wrote: > Anyway, since we created these methods, they became an attractive nuisance, > and thousands of users reach for them who would have been better off in > every way using an immutable collection. Our fondest desire is to one day > be able to delete them. So, obviously, my strong recommendation is not to > add these to ArrayList, etc. I agree with Kevin's warning here. Please, (1) make the immutable version easy to get (List.of not ImmutableList.of), and require users to thoughtfully opt into mutability (new ArrayList not ArrayList.of). — John
- Previous message: RFC: draft API for JEP 269 Convenience Collection Factories
- Next message: RFC: draft API for JEP 269 Convenience Collection Factories
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]