United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 6518061 REGRESSION: MBean introspection rejects interface if it inherits same getter more than once
6518061 : REGRESSION: MBean introspection rejects interface if it inherits same getter more than once

Details
Type:
Bug
Submit Date:
2007-01-26
Status:
Resolved
Updated Date:
2010-07-29
Project Name:
JDK
Resolved Date:
2007-03-24
Component:
core-svc
OS:
generic
Sub-Component:
javax.management
CPU:
generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:
6u2

Related Reports
Backport:
Duplicate:

Sub Tasks

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.
                                     
2007-01-29
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.
                                     
2007-01-26
EVALUATION

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

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



Hardware and Software, Engineered to Work Together