RFR: 8278461: Use Executable.getSharedParameterTypes() instead of Executable.getParameterTypes() in trusted code [v2]
Сергей Цыпанов
duke at openjdk.java.net
Mon Jan 10 10:02:20 UTC 2022
On Mon, 10 Jan 2022 09:38:15 GMT, Сергей Цыпанов <duke at openjdk.java.net> wrote:
>> src/java.base/share/classes/java/lang/reflect/Executable.java line 313:
>>
>>> 311: // getParameterTypes().
>>> 312: if (!genericInfo) {
>>> 313: return getSharedParameterTypes();
>>
>> Since this returns the trusted array it delegates responsibility to the callers of `getAllGenericParameterTypes` to not mutate or further expose/leak the parameter type array. This needs to at least be called out in the method specification. The comment here needs to be updated, as well. Is the added fragility in this case worth the performance win?
>
> I agree about the spec and comment. I think we have nothing to worry about in this case as `Executable` is sealed and `getAllGenericParameterTypes()` is package-private, so it never gets out of JDK codebase. As of its current usage we only read from returned `Type[]`. Lot's of frameworks utilize reflection, so I think we should try to make it as fast as possible
P.S. I think I'd better revert this
-------------
PR: https://git.openjdk.java.net/jdk/pull/6782
More information about the core-libs-dev
mailing list