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

Update MXBean specification and implementation to extend mapping of CompositeType to records

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P3
    • Resolution: Approved
    • Fix Version/s: 17
    • Component/s: core-svc
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      source
    • Compatibility Risk:
      low
    • Compatibility Risk Description:
      Hide
      It is possible that someone may have tried to use a record class that has both components and getters, and provided an annotation for a non canonical constructor based on getters instead of record components. This could be a problem if the name of the getters do not correspond to name of records component - that is if the record component are x, y, and the getters are getA, getB, since the new implementation will ignore getters.
      Show
      It is possible that someone may have tried to use a record class that has both components and getters, and provided an annotation for a non canonical constructor based on getters instead of record components. This could be a problem if the name of the getters do not correspond to name of records component - that is if the record component are x, y, and the getters are getA, getB, since the new implementation will ignore getters.
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      This RFE proposes to update the MXBean specification to define a mapping for records

      Problem

      JEP 395: Records defines Record classes, a new kind of class in the Java language, which help model plain data aggregates. The Open MBean specification defines the notion of CompositeType and CompositeData to model generic data aggregates. The CompositeData interface specifies the behavior of a specific type of complex open data objects which represent composite data structures. The MXBean framework defines rules to map plain java aggregates to CompositeData (and CompositeType). Record classes also represent composite data structures (aggregates), but are not currently supported out-of-the-box by the MXBean framework.

      The MXBean framework currently relies on the presence of getter methods and annotated constructors to map CompositeData instances to plain java aggregates. The specification and implementation of MXBeans could be extended to define a mapping to record classes. The record component accessors can be used as getters, and a record can be easily reconstructed from a CompositeData through the record canonical constructor. A clear advantage of records over plain java objects is that the canonical constructor will not need to be annotated in order to map composite data property names to constructor parameter names.

      Solution

      Update the MXBean specification and implementation to recognize record classes, and use the information provided by the record components to implement the mapping to CompositeData.

      Specification

      The @javax.management.MXBean class level API documentation is updated to define a mapping to records. See the sdiff and the generated API documentation in the attached zip file (the full webrev is also included)

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dfuchs Daniel Fuchs
              Reporter:
              dfuchs Daniel Fuchs
              Reviewed By:
              Chris Hegarty, Mandy Chung
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: