RFR: 8311162: Simplify and modernize equals and hashCode for java.net
Pavel Rappo
prappo at openjdk.org
Fri Jun 30 09:31:45 UTC 2023
Please review this PR to use modern APIs and language features to simplify `equals` and `hashCode` for the java.net package.
Note, in NetworkInterface we could do even more and change this:
for (InetAddress thisAddr : this.addrs) {
boolean found = false;
for (InetAddress thatAddr : that.addrs) {
if (thisAddr.equals(thatAddr)) {
found = true;
break;
}
}
if (!found) {
return false;
}
}
return true;
to this:
return Set.of(that.addrs).containsAll(Set.of(this.addrs));
But arguably, the first option is already better enough than what was there before.
-------------
Commit messages:
- Initial commit
Changes: https://git.openjdk.org/jdk/pull/14726/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14726&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8311162
Stats: 41 lines in 3 files changed: 10 ins; 18 del; 13 mod
Patch: https://git.openjdk.org/jdk/pull/14726.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/14726/head:pull/14726
PR: https://git.openjdk.org/jdk/pull/14726
More information about the net-dev
mailing list