LinkedHashMap adds an errant serializable field

XMLWordPrintable

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

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

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

              Created:
              Updated:
              Resolved: