RFR: 8335637: Add explicit well-behaved expectations to Object.{toString, hashCode} [v2]

Pavel Rappo prappo at openjdk.org
Mon Jul 8 19:21:32 UTC 2024


On Mon, 8 Jul 2024 19:12:37 GMT, Joe Darcy <darcy at openjdk.org> wrote:

> PS There are cases where cyclic structures are not supported, such as in java.util.Set:

There are algorithms that also don't support that:

    /**
     * Returns a hash code based on the "deep contents" of the specified
     * array.  If the array contains other arrays as elements, the
     * hash code is based on their contents and so on, ad infinitum.
     * It is therefore unacceptable to invoke this method on an array that
     * contains itself as an element, either directly or indirectly through
     * one or more levels of arrays.  The behavior of such an invocation is
     * undefined.
    
     ...

     */
    public static int deepHashCode(Object[] a) {

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20063#discussion_r1669161910


More information about the core-libs-dev mailing list