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

AbstractMap unnecessarily initializes two volatiles to null

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P3
    • 9
    • 8
    • core-libs

    Backports

      Description

        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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                  Created:
                  Updated:
                  Resolved: