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

Remove Enum[0] constants from EnumSet and EnumMap

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P5
    • 9
    • None
    • core-libs

    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

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

              Dates

                Created:
                Updated:
                Resolved: