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" <[email protected]> > À: "Kevin Bourrillion" <[email protected]> > Cc: "core-libs-dev" <[email protected]> > 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 <[email protected]> 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
