On Fri, 13 May 2022 12:19:08 GMT, Сергей Цыпанов <d...@openjdk.java.net> wrote:
>> 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 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