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

Remove the caching fields in AbstractMap

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P3 P3
    • 25
    • 22
    • core-libs
    • None

      The immutable maps that are available via the static factories `Map::of` cannot return `@ValueBased` maps because `AbstractMap` declares fields.

      By removing these caching fields in `AbstractMap`, we can make the immutable maps `@ValueBased` and at the same time, performance is likely improved because the JVM is probably able to optimize away object creation anyway via escape analysis. Also, all maps will occupy less space as we get rid of a number of objects and references stored for each map.

      In addition, several Map implementations have their own copies of the cached fields (even though they inherit from AbstractMap) and cache views in the same way. These should be removed as well.

            pminborg Per-Ake Minborg
            pminborg Per-Ake Minborg
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: