java.jmx

Eliminate several uses of reflection in java.jmx

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code

Description

There are a fair number of occurrences of reflection in java.jmx that can be eliminated with the addition of suitable type hints.

Activity

Hide
Andy Fingerhut added a comment -

jmx-9-eliminate-reflection-v1.txt dated Oct 28 2012 eliminates most reflection warnings from java.jmx.

I would recommend that you check the type hints carefully before applying this, in case I messed some of them up. I am not familiar with javax.management library usage. I simply did a lot of looking at method signatures for methods used in the code in the Java library docs.

In particular, I wasn't sure whether connection should be a javax.management.MBeanServer or MBeanServerConnection. MBeanServerConnection is good enough for most of the code, but for the .registerMBean method invocation in register-mbean it needs to be a MBeanServer to avoid reflection. Perhaps it should be MBeanServer everywhere? My main question is whether that would limit the code's generality too much.

Show
Andy Fingerhut added a comment - jmx-9-eliminate-reflection-v1.txt dated Oct 28 2012 eliminates most reflection warnings from java.jmx. I would recommend that you check the type hints carefully before applying this, in case I messed some of them up. I am not familiar with javax.management library usage. I simply did a lot of looking at method signatures for methods used in the code in the Java library docs. In particular, I wasn't sure whether connection should be a javax.management.MBeanServer or MBeanServerConnection. MBeanServerConnection is good enough for most of the code, but for the .registerMBean method invocation in register-mbean it needs to be a MBeanServer to avoid reflection. Perhaps it should be MBeanServer everywhere? My main question is whether that would limit the code's generality too much.
Andy Fingerhut made changes -
Field Original Value New Value
Attachment jmx-9-eliminate-reflection-v1.txt [ 11637 ]
Andy Fingerhut made changes -
Patch Code [ 10001 ]
Hide
Nick Bailey added a comment - - edited

Well it shouldn't be MBeanServer everywhere. When using the with-connection macro connection is a RemoteMBeanServerConnection and 'registerMBean' isn't a defined method.

I'm thinking perhaps we just change register-mbean to always get the local JMX server rather than using the connection binding. You can't register mbeans with a remote jmx server.

Show
Nick Bailey added a comment - - edited Well it shouldn't be MBeanServer everywhere. When using the with-connection macro connection is a RemoteMBeanServerConnection and 'registerMBean' isn't a defined method. I'm thinking perhaps we just change register-mbean to always get the local JMX server rather than using the connection binding. You can't register mbeans with a remote jmx server.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: