Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8048330 JEP 269: Convenience Factory Methods for Collections
  3. JDK-8166365

Small immutable collections should provide optimized implementations when possible

XMLWordPrintable

    • Icon: Sub-task Sub-task
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 9
    • core-libs

      Most old empty and single-element java.util.Collections classes override hashCode, contains, containsAll, providing optimized implementations, whereas the default implementations inherited from AbstractSet/List/Map typically are implemented using iterators. The constant sized collections in ImmutableCollections (Set0,1,2, Map0,1, List0,1,2) doesn't. This leads to a surprising amount of allocations during startup when using Set.of in place of Collections.singleton etc

      Implementing these for at least Set0,1,2 can provably help startup performance of jigsaw after converting from Collections.emptySet/singleton/unmodifiableSets to Set.of in the bootstrap (which has advantages to footprint).

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

              Created:
              Updated:
              Resolved: