RFR: 8282662: Use List.of() factory method to reduce memory consumption [v3]

Сергей Цыпанов duke at openjdk.java.net
Fri May 13 06:30:47 UTC 2022


On Thu, 12 May 2022 14:14:38 GMT, Weijun Wang <weijun at openjdk.org> wrote:

>> Сергей Цыпанов has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8282662: Revert dubious changes in MethodType
>
> src/java.base/share/classes/sun/security/validator/EndEntityChecker.java line 119:
> 
>> 117:     // TLS key exchange algorithms requiring keyEncipherment key usage
>> 118:     private static final Collection<String> KU_SERVER_ENCRYPTION =
>> 119:         Arrays.asList("RSA");
> 
> I understand that you haven't modified the `KU_SERVER_KEY_AGREEMENT` on line 122 because it has 4 elements. However, these 2 nearby lines using different styles look a little strange to me. Why restrict the number to 0, 1, and 2? If we have defined methods with up to 9 arguments, does that mean the new type is suitable for 9 elements?

The reason is that for the cases of length 0, 1, 2 we don't create underlying array as we do for larger number of elements. In other words when we replace `Arrays.asList()` with `List.of()` we win only for 0, 1 and 2 elements.

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

PR: https://git.openjdk.java.net/jdk/pull/7729



More information about the security-dev mailing list