<i18n dev> RFR: 5066247: Refine the spec of equals() and hashCode() for j.text.Format classes [v4]

Naoto Sato naoto at openjdk.org
Wed Sep 6 22:11:40 UTC 2023


On Wed, 6 Sep 2023 20:52:10 GMT, Justin Lu <jlu at openjdk.org> wrote:

>> Please review this PR and [CSR](https://bugs.openjdk.org/browse/JDK-8315720) which refines the spec of `equals()` and `hashCode()` in `java.text.Format` related classes.
>> 
>> The current spec for most of these methods is either  "_Overrides <method_name>_" or are incomplete/wrong (i.e. see `ChoiceFormat`).
>> 
>> This fix adjusts the spec to provide a consistent definition for the overridden methods and specify what is being compared/used to generate a hash code value.
>> 
>> For implementations that use at most a few fields, the values are stated, otherwise a more general term is used as a substitution (i.e. see `DecimalFormat`).
>
> Justin Lu has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - CSR review: Adjust equals wording, improve correctness of hashCode definitions
>  - CSR review: replace implNote with implSpec

src/java.base/share/classes/java/text/CompactNumberFormat.java line 221:

> 219: 
> 220:     // Non-transient / non-static fields should be added to hashCode impl
> 221: 

Did you mean `equals()`? `hashCode()` may not have all the non-transient fields.

src/java.base/share/classes/java/text/CompactNumberFormat.java line 2384:

> 2382:      *
> 2383:      * All fields of this class that are non-transient and non-static are used
> 2384:      * to calculate the hash code value.

Is this `All` correct?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15459#discussion_r1317879503
PR Review Comment: https://git.openjdk.org/jdk/pull/15459#discussion_r1317880046


More information about the i18n-dev mailing list