JDK-8227432 : Add serialVersionUID to EnumSet class
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.util:collections
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 13
  • Submitted: 2019-07-09
  • Updated: 2019-07-10
  • Resolved: 2019-07-10
Related Reports
CSR :  
Description
Summary
-------
Add explicit serialVersionUID declaration to java.util.EnumSet class to match value computed from JDK 8 EnumSet.

Problem
-------
JDK 8 did not declare a serialVersionUID for java.util.EnumSet, in the mistaken belief it was unnecessary because of the use of the serialization proxy pattern. The value was thus computed based on the class members. JDK 9 and JDK 10 included changes to the EnumSet class implementation that changed the computed serialVersionUID value. While this doesn't affect serialized instances of EnumSet (because of the proxy) it does affect serialization of the EnumSet class itself. Thus, serialization of the EnumSet class in JDK 8 and earlier releases is incompatible with JDK 9 and later releases.

Solution
--------
Add to the EnumSet class a serialVersionUID field initialized to the value corresponding to JDK 8 version of EnumSet

Specification
-------------
The serialized form of java.util.EnumSet (in serialized-form.html) will declare that its serialVersionUID field has the value 1009687484059888093L:

    private static final long serialVersionUID = 1009687484059888093L;
Comments
Moving to Approved.
10-07-2019