Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8148044

Remove Enum[0] constants from EnumSet and EnumMap

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P5
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:

      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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                redestad Claes Redestad
                Reporter:
                redestad Claes Redestad
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: