RFR: JDK-8291509 Minor cleanup could be done in sun.security [v4]

Mark Powers mpowers at openjdk.org
Fri Sep 2 04:20:00 UTC 2022


On Thu, 1 Sep 2022 03:40:41 GMT, Weijun Wang <weijun at openjdk.org> wrote:

>> Mark Powers has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   comments from Sean and Max
>
> src/java.base/share/classes/sun/security/rsa/RSAPadding.java line 335:
> 
>> 333:     private byte[] unpadV15(byte[] padded) throws BadPaddingException {
>> 334:         int k = 0;
>> 335:         boolean bp = padded[k++] != 0;
> 
> The original code looks more clear.

I'll keep the original code.

> src/java.base/share/classes/sun/security/tools/keytool/Main.java line 3534:
> 
>> 3532:             Object[] source = {alias};
>> 3533:             if (otherKeyPass != null) {
>> 3534:                 System.err.println(form.format(source));
> 
> You can move the line above out as well. It's also the same.

I can't factor them out because one is `println` and the other is `print`.

> src/java.base/share/classes/sun/security/x509/AVA.java line 446:
> 
>> 444:             if (embeddedHex.size() > 0) {
>> 445:                 // add space(s) before embedded hex bytes
>> 446:                 temp.append(" ".repeat(Math.max(0, spaceCount)));
> 
> `spaceCount` is never negative.

Changed to `repeat(spaceCount)`.

> src/java.base/share/classes/sun/security/x509/AVA.java line 462:
> 
>> 460:             } else {
>> 461:                 // add space(s)
>> 462:                 temp.append(" ".repeat(Math.max(0, spaceCount)));
> 
> `spaceCount` is never negative.

Changed to `repeat(spaceCount)`.

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

PR: https://git.openjdk.org/jdk/pull/9972



More information about the security-dev mailing list