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

    Details

    • Type: Sub-task
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:

      Description

      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).

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: