JDK-5092502 : Add methods for class interrogation to DynamicMBean
  • Type: Enhancement
  • Component: core-svc
  • Sub-Component: javax.management
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2004-08-26
  • Updated: 2008-01-24
  • Resolved: 2008-01-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 7
7Resolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
It would be useful if DynamicMBean had the following methods:

public boolean isInstanceOf(String className);
public ClassLoader getClassLoader();

The isInstanceOf method would be called by MBeanServer.isInstanceOf, and would allow an MBean to say whether it should be considered to be an instance of the named class or not.  For example, if you create a StandardMBean like this:
    new javax.management.StandardMBean(impl, MyMBean.class);
then MBeanServer.isInstanceOf(objectName, MyMBean.class.getName()) should return true.  Today StandardMBean only returns true if the StandardMBean class itself is a subclass of the named class.  Similarly for Model MBeans.

The getClassLoader method would be called by MBeanServer.getClassLoaderFor.  The usage would be similar.  For example, in the StandardMBean example above, it would return MyMBean.class.getClassLoader() or maybe impl.getClassLoader().

There are some compatibility requirements.  We cannot in fact add new methods to the DynamicMBean interface, because existing code that implements that interface would then no longer compile, since it would not implement the new methods.  Therefore there needs to be a new subinterface of DynamicMBean, say DynamicMBean2, ExtendedDynamicMBean, ClassAwareDynamicMBean, or whatever.

Concerning the StandardMBean class, having it return different values for isInstanceOf and getClassLoaderFor from what it returns today would be an incompatible change and could break existing code.  Therefore it should only do this if explicitly asked to through a new API, for example a new constructor with a boolean argument that says whether to do this or not.

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mustang
01-09-2004

PUBLIC COMMENTS .
01-09-2004

EVALUATION API change, should be considered for Mustang (JDK 6.0). ###@###.### 2004-08-26
26-08-2004

WORK AROUND You can get StandardMBean to be an instance of MyMBean by subclassing it, i.e. something like this: public class MyStandardMBean extends implements MyMBean { public MyStandardMBean() { super(MyMBean.class) } ... } Now MBeanServer.isInstanceOf(objectName, MyMBean.class.getName()) will return true. However, this option isn't always available. ###@###.### 2004-08-26
26-08-2004