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

MXBean conversion of Maps fails if Map key is not Comparable

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 6
    • core-svc
    • None
    • b53
    • generic
    • generic

      An attempt to create an MXBean that has an attribute of type Map<K,V>, where K is a type that is not Comparable, produces an exception when reconstructing the value of that attribute. The code incorrectly tries to make a TreeMap. The particular case that fails is when implementing java.lang.management.ThreadMXBean with the generic MXBean framework. It gets an exception like this:
      java.lang.ClassCastException: java.lang.management.ThreadInfo cannot be cast to java.lang.Comparable
      at java.util.TreeMap.compare(TreeMap.java:1093)
      at java.util.TreeMap.put(TreeMap.java:465)
      at com.sun.jmx.mbeanserver.OpenConverter$TabularConverter.fromOpenValue(OpenConverter.java:728)
      at com.sun.jmx.mbeanserver.ConvertingMethod.fromOpenReturnValue(ConvertingMethod.java:117)
      at com.sun.jmx.mbeanserver.MXBeanProxy.invoke(MXBeanProxy.java:149)
      at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:307)
      at $Proxy0.getAllLockedMonitors(Unknown Source)

      The type of the getAllLockedMonitors method is Map<ThreadInfo,MonitorInfo[]>.

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: