RFR: 8282662: Use List/Set.of() factory methods to reduce memory consumption [v3]
Сергей Цыпанов
duke at openjdk.java.net
Sat Mar 26 19:27:40 UTC 2022
On Thu, 10 Mar 2022 08:52:17 GMT, Сергей Цыпанов <duke at openjdk.java.net> wrote:
>> `List.of()` along with `Set.of()` create unmodifiable `List/Set` but with smaller footprint comparing to `Arrays.asList()` / `new HashSet()` when called with vararg of size 0, 1, 2.
>>
>> In general replacement of `Arrays.asList()` with `List.of()` is dubious as the latter is null-hostile, however in some cases we are sure that arguments are non-null. Into this PR I've included the following cases (in addition to those where the argument is proved to be non-null at compile-time):
>> - `MethodHandles.longestParameterList()` never returns null
>> - parameter types are never null
>> - interfaces used for proxy construction and returned from `Class.getInterfaces()` are never null
>> - exceptions types of method signature are never null
>
> Сергей Цыпанов has updated the pull request incrementally with one additional commit since the last revision:
>
> 8282662: Revert dubious changes in MethodType
There were changes with `Set.of()`, but I've reverted them as dubious. I'll rename the ticket and PR's title.
As of the second question I didn't look namely for `Collections.addAll(set, elements)`, if I find any feasible for replacement with `Set.of()` then I'll add it.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7729
More information about the security-dev
mailing list