RFR: JDK-8291509 Minor cleanup could be done in sun.security [v3]
Weijun Wang
weijun at openjdk.org
Wed Aug 31 22:28:38 UTC 2022
On Wed, 31 Aug 2022 22:23:42 GMT, Mark Powers <mpowers at openjdk.org> wrote:
>> src/java.base/share/classes/sun/security/pkcs10/PKCS10Attributes.java line 184:
>>
>>> 182: return false;
>>> 183: PKCS10Attribute thisAttr, otherAttr;
>>> 184: String key;
>>
>> This whole `toString` method can be enhanced. Can we just compare `this.map.equals(that.map)`?
>
> Don't know what you mean about changing `toString`. I could change `equals` to something like:
>
>
> public boolean equals(Object other) {
> if (!(other instanceof PKCS10Attributes))
> return false;
>
> Collection<PKCS10Attribute> othersAttribs =
> ((PKCS10Attributes)other).getAttributes();
> PKCS10Attribute[] attrs =
> othersAttribs.toArray(new PKCS10Attribute[0]);
> PKCS10Attributes foo = new PKCS10Attributes(attrs);
> return this.map.equals(foo.map);
> }
Sorry, I meant `equals`. Why cannot we just compare with `other.map`?
-------------
PR: https://git.openjdk.org/jdk/pull/9972
More information about the security-dev
mailing list