On Wed, 10 Jun 2026 15:26:28 GMT, Chen Liang <[email protected]> wrote:
>> src/java.base/share/classes/java/lang/reflect/package-info.java line 73:
>>
>>> 71: * to produce a {@link MethodHandle} that performs no additional access
>>> checks.
>>> 72: * If the accessed declaration is a member, the single check is
>>> performed
>>> 73: * against the correct class or interface of the member. In the
>>> example above,
>>
>> The new AC section starts with text to show that reflect APIs are caller
>> sensitive and there is access check at each call. It feels like sentences
>> on when the access check is done with method handles should follow that. I
>> think that would flow better so that the issue can inherited methods isn't
>> in the middle of the section.
>
> I am advertising MethodHandles as the preferred alternative to legacy
> reflective invocation instead of comparing the two; I am trying to emphasize
> the correct owner is being checked. I don't think your proposed refactor
> accomplishes the goal better, but some refactoring is definitely necessary
> because you failed to see this as an advertisement.
A significant difference between the old and new reflection APIs is where the
access check is done. Right now the section has this topic in the first
paragraph (old reflection) and last paragraph (new reflection). It feels like
the first two sentences in the last paragraph should follow the first section
of the first paragraph. I think that will fix the structural issue with this
section, and help with your goal to promote the use of method handles (someone
reading this should be able to quickly see that there aren't any access checks
once they obtain the method handle).
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28685#discussion_r3389609127