RFC: draft API for JEP 269 Convenience Collection Factories
stuart.marks at oracle.com
Sat Oct 17 16:46:24 UTC 2015
On 10/10/15 6:55 AM, Remi Forax wrote:
> There is an issue with LinkedHashMap (resp LinkedHashSet),
> it inherits from HashMap /facepalm/, and static methods are accessible through class inheritance /facepalm/.
> So if LinkedHashMap doesn't declare some methods of(),
> will return a HashMap :(
Thanks for pointing this out. I had forgotten about "inheritance" of static
methods. /Facepalm/ indeed. The original proposal (July 2014) avoided this issue
by adding static methods only on interfaces, which are *not* inherited. When we
added statics on concrete classes this problem returned.
(I view calling an "inherited" class static method to be poor coding style, but
neither javac nor NetBeans warns about it.)
Well, perhaps we won't be adding static factories to the concrete collections
after all, so maybe we can dodge this issue. See messages downthread.
More information about the core-libs-dev