Hashcode needs to be reset to -1 to force its recalculation on next call, after 
deserialization.

The change in the readResolve() method is the fix for this problem.  While here 
I added similar lines in other methods that may update fields (although these 
are noted as not supported, they change a class named "immutable).

Added a test.  There is a test for serialization for this class, but I found it 
clearer to add the test for this specific recently discovered issue in its own 
test file.

-------------

Commit messages:
 - spelling
 - Exception name
 - whitespace
 - whitespace
 - 8358624: ImmutableDescriptor violates equals/hashCode contract after 
deserialization

Changes: https://git.openjdk.org/jdk/pull/25758/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=25758&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8358624
  Stats: 82 lines in 2 files changed: 82 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/25758.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/25758/head:pull/25758

PR: https://git.openjdk.org/jdk/pull/25758

Reply via email to