Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8274299

Make Method/Constructor/Field accessors @Stable

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 18
    • Component/s: core-libs
    • Labels:
      None

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              plevart Peter Levart
              Reporter:
              plevart Peter Levart
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: