JDK-6518061 : REGRESSION: MBean introspection rejects interface if it inherits same getter more than once
  • Type: Bug
  • Component: core-svc
  • Sub-Component: javax.management
  • Affected Version: 6
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2007-01-26
  • Updated: 2010-07-29
  • Resolved: 2007-03-24
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.
JDK 6 JDK 7
6u2 b01Fixed 7Fixed
Related Reports
Duplicate :  
Description
When an MBean interface inherits two getter methods with the same signature from two different ancestors, the reflection code falsely rejects the MBean interface.  This worked fine in JDK 5.0 so it is a regression.

For example, the following test:

import java.util.*;
import java.lang.reflect.*;
import javax.management.*;

public class MultiGetTest {
    public static interface FooMBean {
	public MBeanNotificationInfo[] getNotificationInfo();
    }

    public static interface BazMBean {
	public MBeanNotificationInfo[] getNotificationInfo();
    }

    public static interface BarMBean extends FooMBean, BazMBean {
    }

    public static class Bar implements BarMBean {
	public MBeanNotificationInfo[] getNotificationInfo() {
	    return null;
	}
    }

    public static void main(String[] args) throws Exception {
	new StandardMBean(new Bar(), BarMBean.class);
    }
}

produces the following exception:

Exception in thread "main" javax.management.NotCompliantMBeanException: Attribute NotificationInfo has more than one getter
        at com.sun.jmx.mbeanserver.MBeanAnalyzer.initMaps(MBeanAnalyzer.java:139)
        at com.sun.jmx.mbeanserver.MBeanAnalyzer.<init>(MBeanAnalyzer.java:100)
        at com.sun.jmx.mbeanserver.MBeanAnalyzer.analyzer(MBeanAnalyzer.java:88)
        at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.getAnalyzer(StandardMBeanIntrospector.java:48)
        at com.sun.jmx.mbeanserver.MBeanIntrospector.getPerInterface(MBeanIntrospector.java:163)
        at com.sun.jmx.mbeanserver.MBeanSupport.<init>(MBeanSupport.java:147)
        at com.sun.jmx.mbeanserver.StandardMBeanSupport.<init>(StandardMBeanSupport.java:81)
        at javax.management.StandardMBean.construct(StandardMBean.java:169)
        at javax.management.StandardMBean.<init>(StandardMBean.java:200)
        at MultiGetTest.main(MultiGetTest.java:24)

Comments
EVALUATION In fact this bug is basically the same as 6398884, which describes the equivalent problem for operations as opposed to attributes. We already fixed that bug in JDK 7 and therefore also this one as a side effect. So we can just port that fix back to JDK 6.
29-01-2007

WORK AROUND Eliminate one of the duplicate methods, or add the same method declaration to the common descendant interface (BarMBean in the test case).
26-01-2007

EVALUATION This problem has shown up for clients migrating from JDK 5.0 to JDK 6. The fix should be straightforward.
26-01-2007

SUGGESTED FIX In com.sun.jmx.mbeanserver.MBeanAnalyzer.overrides, the check that considers that one method overrides another only if it is lower in the inheritance hierarchy is not really necessary. We can consider that if two methods in unrelated interfaces have the same signature then either overrides the other. The only purpose of the check is to eliminate one of the methods.
26-01-2007