5066247: Refine the spec of equals() and hashCode() for j.text.Format classes

Reviewed-by: naoto, darcy
This commit is contained in:
Justin Lu 2023-10-02 05:06:45 +00:00
parent 93f662f4fc
commit 8fcf70e931
9 changed files with 141 additions and 25 deletions

View file

@ -737,7 +737,17 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
}
/**
* Override equals.
* Compares the specified object with this {@code DecimalFormatSymbols} for equality.
* Returns true if the object is also a {@code DecimalFormatSymbols} and the two
* {@code DecimalFormatSymbols} objects represent the same set of symbols.
*
* @implSpec This method performs an equality check with a notion of class
* identity based on {@code getClass()}, rather than {@code instanceof}.
* Therefore, in the equals methods in subclasses, no instance of this class
* should compare as equal to an instance of a subclass.
* @param obj object to be compared for equality
* @return {@code true} if the specified object is equal to this {@code DecimalFormatSymbols}
* @see Object#equals(Object)
*/
@Override
public boolean equals(Object obj) {
@ -767,7 +777,11 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
}
/**
* Override hashCode.
* {@return the hash code for this {@code DecimalFormatSymbols}}
*
* @implSpec Non-transient instance fields of this class are used to calculate
* a hash code value which adheres to the contract defined in {@link Objects#hashCode}.
* @see Object#hashCode()
*/
@Override
public int hashCode() {