Integrated: 8282662: Use List.of() factory method to reduce memory consumption
Сергей Цыпанов
duke at openjdk.java.net
Wed Jun 1 13:35:13 UTC 2022
On Mon, 7 Mar 2022 15:11:50 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
This pull request has now been integrated.
Changeset: 168b226b
Author: Sergey Tsypanov <sergei.tsypanov at yandex.ru>
Committer: Roger Riggs <rriggs at openjdk.org>
URL: https://git.openjdk.java.net/jdk/commit/168b226b0f7a3b067bf11616e5a92908f63be450
Stats: 12 lines in 4 files changed: 1 ins; 2 del; 9 mod
8282662: Use List.of() factory method to reduce memory consumption
Reviewed-by: redestad, rriggs
-------------
PR: https://git.openjdk.java.net/jdk/pull/7729
More information about the security-dev
mailing list