United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6177524 MBeanServerInvocationHandler should not forward Object methods to proxied MBean
JDK-6177524 : MBeanServerInvocationHandler should not forward Object methods to proxied MBean

Details
Type:
Bug
Submit Date:
2004-10-12
Status:
Resolved
Updated Date:
2010-07-29
Project Name:
JDK
Resolved Date:
2005-02-05
Component:
core-svc
OS:
generic,windows_xp
Sub-Component:
javax.management
CPU:
x86,generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
5.0,6
Fixed Versions:

Related Reports
Relates:

Sub Tasks

Description
MBeanServerInvocationHandler is specified to forward the methods hashCode(), toString(), and equals(Object) to the proxied MBean.  This is basically never what you want, and in particular means that you cannot reasonably use an MBean proxy as a key in a HashMap (for example to look up a cached MBeanInfo for the proxy).  MBeanServerInvocationHandler should only forward these methods if they are explicitly mentioned in the MBean interface for which it is a handler.  This can be discovered by reflecting on the class of the proxy parameter to MBeanServerInvocationHandler.invoke.  Its first superinterface will be the MBean interface, and it can be examined to see whether it contains the method in question.
###@###.### 10/12/04 11:07 GMT

                                    

Comments
EVALUATION

This is arguably an incompatible change.  It is however very unlikely to break existing code, and in fact is much more likely to fix existing code that had an unrevealed bug.  If a scenario in which code might be broken is found, we could add a new form of MBeanServerInvocationHandler.newProxyInstance with a parameter that says whether or not the Object methods should be forwarded.  It might be best in that case to put the method in a new class called MBeanFactory since MBeanServerInvocationHandler.newProxyInstance is very verbose and non-obvious.  MBeanFactory could also contain methods for creating instances of the StandardMBean class.
This should be addressed for Mustang.
###@###.### 10/12/04 11:07 GMT

There are other problems: when calling the method newProxyInstance and passing null for the MBeanServerConnection parameter, it will get an NullPointerException when calling later a method on the Proxy object; if passing null for the ObjectName parameter, it will get a javax.management.RuntimeOperationsException which wraps an IllegalArgumentException when calling later a method on the Proxy object.
###@###.### 2004-12-15 16:35:10 GMT
                                     
2004-10-12



Hardware and Software, Engineered to Work Together