RFR: 8271820: Implementation of JEP 416: Reimplement Core Reflection with Method Handle [v16]
Claes Redestad
redestad at openjdk.java.net
Sun Nov 14 00:59:42 UTC 2021
On Sat, 13 Nov 2021 23:56:20 GMT, Martin Grigorov <duke at openjdk.java.net> wrote:
>> Mandy Chung has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 43 commits:
>>
>> - fix copyright header and typo
>> - improve documentation of AccessorUtils
>> - Merge branch 'master' of https://github.com/openjdk/jdk into reimplement-method-invoke
>> - Fall back to the VM native reflection support if method handle cannot be created
>> - fix bug id in test
>> - Merge
>> - Merge branch 'master' of https://github.com/openjdk/jdk into reimplement-method-invoke
>> - Merge branch 'master' of https://github.com/openjdk/jdk into reimplement-method-invoke
>> - Separate paramFlgas into paramCount and flags fields
>> - Minor cleanup. Improve javadoc in CallerSensitiveAdapter
>> - ... and 33 more: https://git.openjdk.java.net/jdk/compare/9a3e9542...46cb306b
>
> Hi,
>
> Apache Wicket tests started failing with JDK 18 b23 and I think it is caused by this PR.
> I've sent an email to Rory O'Donnell and his team because we participate at https://wiki.openjdk.java.net/display/quality/Quality+Outreach
> The email with the explanation of the problem could be seen at https://markmail.org/message/o3gw72bwsfrpaf2n
@martin-g mutating static final fields with reflection `setAccessible(true)` is an ugly hack with partially undefined behavior that can lead to all manners of bugs.. but I think this is an unintentional behavior change.
@mlchung should verify, but it looks like the `MethodHandles.unreflect` API used internally in the new implementation is slightly stricter and ignores the `setAccessible(true)` for the trusted finality check. This added strictness is established behavior for the public `MethodHandles.unreflect` API point, which seem perfectly fine there (the MH API is strictly adhering to regular java access rules). For this new reflection implementation we should probably make an exception to that strictness to be perfectly backwards compatible.
-------------
PR: https://git.openjdk.java.net/jdk/pull/5027
More information about the core-libs-dev
mailing list