Any chance to see EnumSet implement SortedSet in JDK8?
Joe Darcy
joe.darcy at oracle.com
Fri Aug 12 00:27:59 UTC 2011
On 8/11/2011 5:21 PM, Ulf Zibis wrote:
> Am 12.08.2011 01:03, schrieb Joe Darcy:
>> Hello.
>>
>> On 8/11/2011 1:56 PM, Rémi Forax wrote:
>>> On 08/11/2011 10:19 PM, assembling signals wrote:
>>>> Hello, community!
>>>>
>>>> Enum does implement Comparable, while EnumSet does NOT implement
>>>> SortedSet and EnumMap doesn NOT implement SortedMap.
>>>> Should I file a bug report (RFE), would there be a chance to see
>>>> this being implemented in JDK8?
>>>
>>> I've asked the same question with NavigableSet/Map during the JDK6
>>> timeframe
>>> so you should find the answer by Doug Lea on the
>>> concurrency-interest list
>>> concurrency-interest at cs.oswego.edu
>>>
>>> Furthermore, you can't retrofit EnumSet to implement SortedSet
>>> (an interface that already exists)
>>> because since 1.5, a lot of code was written and some may rely on
>>> the fact that EnumSet doesn't implement SortedSet.
>>
>> Actually, that is not the sort of compatibility contract we usually
>> worry about enforcing over time. For example, in JDK 7 I retrofitted
>> the java.io.Closeable interface to several long-standing classes with
>> close methods that were not retrofitted before.
>>
>
> If this is correct, why can't we add method clone to interface
> Cloneable? See Bug ID: 4098033 Cloneable doesn't define .clone
> <http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4098033> .
>
> I think you can add methods (e.g. via adding an interface) to an
> existing *regular* class, but not to an abstract class or interface
> without breaking source compatibility seriously.
> EnumSet is *abstract* class.
>
> Am I wrong, please correct me?
>
> -Ulf
>
EnumSet is an effectively final class since it has no public or
protected constructors. The fact that the class is marked abstract is
an implementation detail in this case. Therefore, augmenting EnumSet to
implement another interface would follow the usual source, binary, and
behavioral compatibility [1] policies we use to evolve the JDK.
-Joe
[1]
http://cr.openjdk.java.net/~darcy/OpenJdkDevGuide/OpenJdkDevelopersGuide.v0.777.html#compatibility
More information about the core-libs-dev
mailing list