RFR: 8311162: Simplify and modernize equals and hashCode for java.net

Pavel Rappo prappo at openjdk.org
Fri Jun 30 13:40:53 UTC 2023


On Fri, 30 Jun 2023 12:00:03 GMT, Mark Sheppard <msheppar at openjdk.org> wrote:

> For NetworkInterface the non Set version is more straight forward and clearer, Set intersection is a little arcane
> Not sure it is possible to assign the same IP address multiple times to an interface, maybe an IPv6 with different scope ids? but I think not.

After eliminating indexes from the loops, they certainly look cleaner: prior to this change, the loops might have given an impression that there was some sort of element matching (correlating by index), which there wasn't. My personal rule of thumb is this: avoid indexing if it's only used to access the *next* element in the iteration.

That said, I'm a bit surprised that you find set equality (not a subset test, but an equality test, as we discussed with @dfuch in this PR) to be more arcane than nested loops.

Anyway, the testing has shown no issues, so unless there is anything else, I'll integrate it shortly.

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

PR Comment: https://git.openjdk.org/jdk/pull/14726#issuecomment-1614665912


More information about the net-dev mailing list