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

Joe Darcy darcy at openjdk.org
Thu Jul 11 21:50:51 UTC 2024


On Thu, 11 Jul 2024 00:06:33 GMT, Stuart Marks <smarks at openjdk.org> wrote:

> 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?

Hmm. In rare cases, I think providing not-quite-actionable advice is on net helpful.

My basic goal here is to convey "when you're implementing these methods, be considerate to your expected users." If that results in some extra contemplation during development or code review about whether or not the worst-case behavior of hashCode/toString/equals is excessive, I think that would be a reasonable outcome from this change.

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

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


More information about the core-libs-dev mailing list