JDK-6392303 : CompositeDataView.toCompositeData should have CompositeType parameter
  • Type: Enhancement
  • Component: core-svc
  • Sub-Component: javax.management
  • Affected Version: 6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2006-03-01
  • Updated: 2017-05-16
  • Resolved: 2006-03-23
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.
6 b78Fixed
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()
    CompositeData toCompositeData(CompositeType ct).

EVALUATION Trivial change. The point where the framework calls toCompositeData already has the required CompositeType available.