JDK-6471916 : HotSpotDiagnostic MXBean's getDiagnosticOptions() should return Map
  • Type: Bug
  • Component: core-svc
  • Sub-Component: java.lang.management
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: generic
  • CPU: generic
  • Submitted: 2006-09-18
  • Updated: 2010-07-29
  • Resolved: 2006-09-18
Related Reports
Relates :  
Description
The HotSpotDiagnosticMXBean (com.sun.management.HotSpotDiagnosticMXBean, a public API) includes the following method:
    List<VMOption> getDiagnosticOptions()
Logically this should be instead:
    Map<String,VMOption> getDiagnosticOptions()
since two options cannot have the same name (presumably).  This would mean that a caller could find the value of a given option by using something like:
    String value = hotSpotDiagnosticProxy.getDiagnosticOptions().get("PrintGC");
With the existing definition, the caller has to iterate over the list to find the element with the name of interest.

Of course it is too late to fix this in JDK 6 and it would be an incompatible change if we made it in JDK 7.  However, we could envision adding a second method getDiagnosticOptionMap() that does return Map<String,VMOption>.

One consequence of the current design is that jconsole cannot show the value of this attribute usefully.  List<VMOption> gets mapped by the MXBean mapping rules into CompositeData[], and jconsole currently doesn't know how to display that cleanly.  (This is bug 6333561.)

Comments
EVALUATION To find the element with the name of interest, you can use hotSpotDiagnosticProxy.getVMOption("PrintGC"); We also consider to add a new diagnostic tab (6350837) for accessing HotSpot specific support.
18-09-2006