RFR(xs): 8199394: Object.hashCode should not mention anything about memory addresses
Remi Forax
forax at univ-mlv.fr
Fri Dec 7 10:31:34 UTC 2018
Hi Stuart,
what about adding "tries to" to the @implSpec section
As much as is reasonably practical, the {@code hashCode} method defined
by class {@code Object} tries to return distinct integers for distinct objects.
otherwise looks good.
Rémi
----- Mail original -----
> De: "Stuart Marks" <stuart.marks at oracle.com>
> À: "core-libs-dev" <core-libs-dev at openjdk.java.net>
> Envoyé: Vendredi 7 Décembre 2018 03:06:58
> Objet: RFR(xs): 8199394: Object.hashCode should not mention anything about memory addresses
> Hi all,
>
> Please review this small update to the Object.hashCode spec to remove mention of
> memory addresses. This also moves the statement about the implementation of
> hashCode in the Object class into an @implSpec section.
>
> Bug:
> https://bugs.openjdk.java.net/browse/JDK-8199394
>
> Patch appended below.
>
> (I will file a CSR before pushing this changeset.)
>
> Thanks,
>
> s'marks
>
>
>
> # HG changeset patch
> # User smarks
> # Date 1544148151 28800
> # Thu Dec 06 18:02:31 2018 -0800
> # Node ID abc83502ef65c408cddd0bb5dd3985ac70946427
> # Parent 0d89f672c62eeec74547c20c822dfde8edbf9b62
> 8199394: Object.hashCode should not mention anything about memory addresses
> Reviewed-by: XXX
>
> diff -r 0d89f672c62e -r abc83502ef65
> src/java.base/share/classes/java/lang/Object.java
> --- a/src/java.base/share/classes/java/lang/Object.java Thu Dec 06 14:34:11 2018
> -0800
> +++ b/src/java.base/share/classes/java/lang/Object.java Thu Dec 06 18:02:31 2018
> -0800
> @@ -94,12 +94,10 @@
> * programmer should be aware that producing distinct integer results
> * for unequal objects may improve the performance of hash tables.
> * </ul>
> - * <p>
> - * As much as is reasonably practical, the hashCode method defined
> - * by class {@code Object} does return distinct integers for
> - * distinct objects. (The hashCode may or may not be implemented
> - * as some function of an object's memory address at some point
> - * in time.)
> + *
> + * @implSpec
> + * As much as is reasonably practical, the {@code hashCode} method defined
> + * by class {@code Object} returns distinct integers for distinct objects.
> *
> * @return a hash code value for this object.
> * @see java.lang.Object#equals(java.lang.Object)
More information about the core-libs-dev
mailing list