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

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


On Fri, 13 May 2022 11:14:29 GMT, ExE Boss <duke at openjdk.java.net> 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/java/lang/reflect/ProxyGenerator.java line 727:
> 
>> 725:             MethodVisitor mv = cw.visitMethod(accessFlags,
>> 726:                     method.getName(), desc, null,
>> 727:                     typeNames(List.of(exceptionTypes)));
> 
> Since `exceptionTypes` is an array, it might be better to keep using `Arrays.asList`, or add an overload for `typeNames` that works on class arrays.

Usually a method declares either no exception, or a couple of them. In the first case `List.of()` doesn't allocate, in the second it allocates an object with 1-2 fields but without an array, so `List.of()` is likely to be more memory-saving

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

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



More information about the security-dev mailing list