RFR: 8336043: Add quality of implementation discussion to Object.{equals, toString, hashCode}

Stuart Marks smarks at openjdk.org
Thu Jul 11 00:08:55 UTC 2024


On Wed, 10 Jul 2024 22:33:54 GMT, Joe Darcy <darcy at openjdk.org> wrote:

> First pass at adding some quality of implementation discussions around the overridable methods of Object.

src/java.base/share/classes/java/lang/Object.java line 48:

> 46:  * to provide reasonable implementations of these methods. In
> 47:  * particular, the implementations should take care to avoid using
> 48:  * excessive memory, computational time, or any other resources.

While it's not wrong, advising against "excessive" usage is so vague as not to be actionable. Given some piece of code it's hard to say whether or not it does anything excessive. Consider a List with a million elements; as a practical matter, any one of these methods requires visiting every element. Is that excessive? Why or why not?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20128#discussion_r1673223579


More information about the core-libs-dev mailing list