default methods inherited by EnumSet and EnumMap

Paul Sandoz paul.sandoz at
Tue Dec 6 20:00:29 UTC 2016

I logged this issue for EnumSet/EnumMap: <>


> On 6 Dec 2016, at 09:53, Martin Buchholz <martinrb at> wrote:
> Almost every core library collection class can benefit from overriding
> those default methods for performance.
> But it hasn't been done consistently - I noticed this myself recently in
> other collection classes; we have an effort under way to fix that for jdk9
> (notably ArrayDeque).  But EnumMap/EnumSet have probably fallen into the
> orphaned bucket.
> On Tue, Dec 6, 2016 at 12:03 AM, Michael Hixson <michael.hixson at>
> wrote:
>> Hello,
>> I notice that EnumSet and EnumMap don't override any of the default
>> methods that were added to collections in Java 8.  Were they
>> specifically considered then avoided during the Java 8 upgrades, or
>> was it simply that no one got around to optimizing them?  Are there
>> existing issues/bugs for optimizing them?  I couldn't find any.
>> As one example:  I suspect that EnumMap.forEach(action) could improve
>> a lot.  Right now it looks like iterating over keySet() and calling
>> get(key) is faster than forEach(action) when it comes to EnumMap
>> (unlike every other Map implementation I tested).
>> -Michael

More information about the core-libs-dev mailing list