On Thu, 19 Jun 2025 11:17:01 GMT, Kevin Walls <kev...@openjdk.org> wrote:

>> 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, as they change a class supposedly 
>> "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.
>
> Kevin Walls has updated the pull request with a new target base due to a 
> merge or a rebase. The incremental webrev excludes the unrelated changes 
> brought in by the merge/rebase. The pull request contains six additional 
> commits since the last revision:
> 
>  - Merge remote-tracking branch 'upstream/master' into 
> 8358624_ImmutableDescriptor_hashcode
>  - spelling
>  - Exception name
>  - whitespace
>  - whitespace
>  - 8358624: ImmutableDescriptor violates equals/hashCode contract after 
> deserialization

src/java.management/share/classes/javax/management/ImmutableDescriptor.java 
line 141:

> 139:             bad = true;
> 140:         if (!bad) {
> 141:             hashCode = -1; // Force recalculation

Nit: Would it make sense to add same comment to the lines: 445, 452,473, 493?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25758#discussion_r2159391491

Reply via email to