RFR: 8311170: Simplify and modernize equals and hashCode in security area [v9]

Pavel Rappo prappo at openjdk.org
Mon Jul 17 11:08:08 UTC 2023


On Mon, 17 Jul 2023 10:15:18 GMT, Daniel Jeliński <djelinski at openjdk.org> wrote:

>> Pavel Rappo has updated the pull request incrementally with five additional commits since the last revision:
>> 
>>  - Feedback: avoid intermediate assignments
>>  - More previously missed cases
>>  - Fix: log hashCode as an unsigned long
>>    
>>    If they don't match, this test fails:
>>    test/jdk/jdk/security/logging/TestX509ValidationLog.java
>>  - Fix: match hashCode implementations
>>    
>>    hashCode in the included classes must match that of
>>    javax.crypto.spec.SecretKeySpec.hashCode.
>>    
>>    If they don't match, this test fails:
>>    test/jdk/javax/crypto/KeyGenerator/CompareKeys.java
>>  - Fix: revert short-circuiting when destroyed
>>    
>>    That change caused this test to fail:
>>    test/jdk/javax/security/auth/kerberos/KerberosHashEqualsTest.java
>
> 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?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14738#discussion_r1265187193



More information about the security-dev mailing list