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

CompositeDataView.toCompositeData should have CompositeType parameter

XMLWordPrintable

    • b78
    • generic
    • generic

      The CompositeDataView interface allows you to specify explicitly how your custom type will be converted into a CompositeData when mapped inside the MXBean framework. But in general the CompositeType of this CompositeData is determined by the framework. Supplying a CompositeData with a different CompositeType may fail.

      For example, suppose your MXBean references the type Map<String,MyCustomType>. This will be mapped into a TabularType with items "key" and "value". The "value" item will have a CompositeType determined by the framework; call it ct. If MyCustomType implements CompositeDataView, then its toCompositeData must return a value where compositeData.getCompositeType() equals ct. Otherwise, the attempt to construct the TabularData will fail because of the type mismatch. And it is nontrivial to figure out what the require CompositeType looks like.

      The proposed solution is simply to change the signature of CompositeDataView.toCompositeData from:
          CompositeData toCompositeData()
      to
          CompositeData toCompositeData(CompositeType ct).

            emcmanus Eamonn McManus
            emcmanus Eamonn McManus
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: