JDK-8274299 : Make Method/Constructor/Field accessors @Stable
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-09-24
  • Updated: 2023-11-03
  • Resolved: 2021-10-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 18
18 b18Fixed
Related Reports
Duplicate :  
Relates :  
Description
Method::methodAccessor and Constructor::constructorAccessor fields are volatile since they are initialized lazily with a reference to appropriate accessor object in order to ensure that the accessor object is safely published to concurrent threads. If we replace volatile modifier with @Stable annotation on those fields, accessor objects are published to other threads via data race. In order for other threads to see the accessor objects fully initialized, their classes have to be modified to allow safe publication via data race. Mostly this can be performed by adding final modifier to their fields.
With such change, benchmarks show improvements in speed of accessing fields and calling methods/constructors via reflection.
Comments
Changeset: 7ad74d82 Author: Peter Levart <plevart@openjdk.org> Date: 2021-10-05 14:16:20 +0000 URL: https://git.openjdk.java.net/jdk/commit/7ad74d82d7117113dd73966a0dd96168adfd6463
05-10-2021