JDK-8309885 : LinkedHashMap adds an errant serializable field
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.util:collections
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 21,22
  • Submitted: 2023-06-13
  • Updated: 2023-06-13
  • Resolved: 2023-06-13
Related Reports
CSR :  
Relates :  
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.)
Comments
Moving to Approved. Added JDK 22 as a fixVersion in case the bots wouldn't recognized "21" as meaning going into JDK's 21 and 22.
13-06-2023