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

LinkedHashMap adds an errant serializable field

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P3
    • 21, 22
    • core-libs
    • None
    • behavioral
    • minimal
    • Restores JDK 20 serialization format.
    • File or wire format
    • SE

    Description

      Summary

      Revert an erroneous change to the serialized format of LinkedHashMap.

      Problem

      A new field putMode had been added to LinkedHashMap in the initial Sequenced Collection implementation (JDK-8266571). Since the class is serializable, this resulted in an unintended change to the serial format.

      Solution

      The field should be marked transient to restore the previous serial format.

      Specification

      @@ -330,7 +330,7 @@ public class LinkedHashMap<K,V>
           static final int PUT_NORM = 0;
           static final int PUT_FIRST = 1;
           static final int PUT_LAST = 2;
      -    int putMode = PUT_NORM;
      +    transient int putMode = PUT_NORM;
      
           // Called after update, but not after insertion
           void afterNodeAccess(Node<K,V> e) {

      (This has the effect of removing the putMode field from the serialized form of LinkedHashMap as documented on the serialized-form.html page of the specification.)

      Attachments

        Issue Links

          Activity

            People

              smarks Stuart Marks
              smarks Stuart Marks
              Brian Burkhalter, Joe Darcy
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: