RFR: 8311170: Simplify and modernize equals and hashCode in security area [v9]
Daniel Jeliński
djelinski at openjdk.org
Mon Jul 17 11:08:09 UTC 2023
On Mon, 17 Jul 2023 10:59:42 GMT, Pavel Rappo <prappo at openjdk.org> wrote:
>> src/java.base/share/classes/sun/security/x509/OtherName.java line 212:
>>
>>> 210: public int hashCode() {
>>> 211: if (myhash == -1) {
>>> 212: myhash = 37 + oid.hashCode() + Arrays.hashCode(nameValue);
>>
>> I think you can drop 37 here. Either that, or use `37 * oid.hashCode()`.
>
> You think it was a typo (+ instead of *) in the original code?
The original code calculated `(37 ** nameValue.length)*(37+oid.hashCode)+Arrays.hashCode`; since you already dropped the multiplication, you can also drop the addition.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14738#discussion_r1265190084
More information about the security-dev
mailing list