RFR: 8274299: Make Method/Constructor/Field accessors @Stable [v2]

Claes Redestad redestad at openjdk.java.net
Tue Sep 28 09:53:57 UTC 2021

On Tue, 28 Sep 2021 08:25:17 GMT, Peter Levart <plevart at openjdk.org> wrote:

>> This patch improves reflective access speed as shown by the included benchmarks:
>> https://jmh.morethan.io/?gists=902f4b43519c4f96c7abcd14cdc2d27d,ac490481e3001c710d75d6071c10b23a
>> ... and is also a prerequisite to make JEP 416 (Reimplement Core Reflection with Method Handle) perform better in some circumstances.
> Peter Levart has updated the pull request incrementally with one additional commit since the last revision:
>   Make Method/Constructor/Field instance fields initialized in the constructors final

Does `Reflection::new_method/...` (which are natively implemented constructors) need any special treatment for them to follow the same semantics as a Java-based constructor w.r.t. final field writes? Or could they be rewritten to call the equivalent java constructor in each case?

We lack a microbenchmark for `Constructor`, but I suspect it might be a similar improvement to annotate the same fields in `Constructor` with  `@Stable`. If not else it seems prudent to be consistent.


PR: https://git.openjdk.java.net/jdk/pull/5694

More information about the core-libs-dev mailing list