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

Parents of MXBean interfaces cannot contain non-MXBean methods even if covariantly overridden

XMLWordPrintable

    • Cause Known
    • 6
    • generic
    • generic

      Suppose you have an interface like this:

      public interface ParentMXBean {
          String getDescription();
          Set<?> getSet();
      }

      This is not a valid MXBean interface because Set<?> is not an allowed type. Now suppose you make a subinterface like this:

      public interface ChildMXBean extends ParentMXBean {
          Set<String> getSet();
      }

      The problematic getSet() method from ParentMXBean has been covariantly overridden with an allowed type Set<String>. ChildMXBean is a valid MXBean interface. You can register it in an MBean Server, and you can make an MXBean Proxy for it.

      But if you make such a ChildMXBean proxy and then call its getDescription() method, you get an exception, "NotCompliantMBeanException: ParentMXBean: Method ParentMXBean.getSet has parameter or return type that cannot be translated into an open type". The problem is that the proxy is seeing getDescription() as defined by ParentMXBean, which triggers an analysis of the ParentMXBean interface.

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

              Created:
              Updated:
              Imported:
              Indexed: