JDK-6177524 : MBeanServerInvocationHandler should not forward Object methods to proxied MBean
  • Type: Bug
  • Component: core-svc
  • Sub-Component: javax.management
  • Affected Version: 5.0,6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,windows_xp
  • CPU: generic,x86
  • Submitted: 2004-10-12
  • Updated: 2017-05-16
  • Resolved: 2005-02-05
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.
6 b23Fixed
Related Reports
Relates :  
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

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