Remove Enum[0] constants from EnumSet and EnumMap

XMLWordPrintable

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

      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

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

              Created:
              Updated:
              Resolved: