On Thu, 6 Jan 2022 16:45:09 GMT, Claes Redestad <redes...@openjdk.org> wrote:
>> `Executable.getParameterTypes()` creates a copy of underlying array which is >> redundant in trusted code when we are sure the action is read-only. > > src/java.base/share/classes/java/lang/reflect/Executable.java line 317: > >> 315: final boolean realParamData = hasRealParameterData(); >> 316: final Type[] genericParamTypes = getGenericParameterTypes(); >> 317: final Type[] nonGenericParamTypes = >> getSharedParameterTypes(); > > (If removing these allocations is important, I note that > `ConstructorRepository.getGenericParameterTypes()` lacks an equivalent to > `getSharedParameterType` for trusted callers) > > Similarly here I'm not sure the win from avoiding the clone is worth > delegating the additional responsibility. You could still do this here if you > add `.clone()` after `nonGenericParamTypes` on L344 @cl4es Do you think it's worth creating a separate PR for `ConstructorRepository.getGenericParameterTypes()`? ------------- PR: https://git.openjdk.java.net/jdk/pull/6782