JDK-8148044 : Remove Enum[0] constants from EnumSet and EnumMap
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util:collections
  • Priority: P5
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2016-01-22
  • Updated: 2019-07-10
  • Resolved: 2016-01-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b103Fixed
Related Reports
Relates :  
Description
EnumSet and EnumMap each have a

private static final Enum<?>[] ZERO_LENGTH_ENUM_ARRAY = new Enum<?>[0];

In EnumMap it's unused, but in EnumSet it's used for serialization purposes: 

    SerializationProxy(EnumSet<E> set) {
        elementType = set.elementType;
        elements = set.toArray(ZERO_LENGTH_ENUM_ARRAY);
    }

Having these constants is hardly justified[1] and incurs an ever so slight startup/footprint cost by loading Enum[].class

[1] http://shipilev.net/blog/2016/arrays-wisdom-ancients/#_caching_the_array