RFR(xs): 8199394: Object.hashCode should not mention anything about memory addresses

Aleksey Shipilev shade at redhat.com
Fri Dec 7 10:30:09 UTC 2018


On 12/7/18 3:06 AM, Stuart Marks wrote:
> # 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)

Looks good to me.

-Aleksey



More information about the core-libs-dev mailing list