AbstractMap unnecessarily initializes two volatiles to null

XMLWordPrintable

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

        In AbstractMap there are two volatile fields that are explicitly set to null as part of initialization.
        This should be unnecessary since all fields are guaranteed to be null.

        public abstract class AbstractMap<K,V> implements Map<K,V> {
        ...
            /**
             * Each of these fields are initialized to contain an instance of the
             * appropriate view the first time this view is requested. The views are
             * stateless, so there's no reason to create more than one of each.
             */
            transient volatile Set<K> keySet = null;
            transient volatile Collection<V> values = null;
        ...
        }


        There might be other similar instance in the JDK that could be fixed at the same time.

              Assignee:
              Mike Duigou
              Reporter:
              Staffan Friberg (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: