(Best Practice) Declaring IOExceptions in MBean interface
Hi,
It is good practice for every method in a Standard MBean interface to be declared to throw java.io.IOException as shown here. This forces the code using the proxy to handle this exception explicitly. Otherwise, a communication problem while using the proxy will show up as the unchecked exception UndeclaredThrowableException wrapping the original IOException
I took this from the Best Practice page. Is this still a valid practice ? Most of the example code don't declare IOExceptions anyway.
Thanks
[537 byte] By [
chihiroa] at [2007-11-14]

Yes, this is still a good idea for the reason given. Examples that don't include it should be updated.
It's not absolutely critical, of course - it just means that you get a more obvious exception in the case of communication failure, and that the compiler will remind you that you need to think about what to do in this case.
Hi,
If you look at the new JMX example we've added to JDK 6
<JDK6_HOME>/sample/jmx/jmx-scandir/index.html you will see that we are
using this pattern there...
See also:
http://blogs.sun.com/jmxetc/entry/an_advanced_jmx_example_for
cheers,
-- daniel
JMX, SNMP, Java, etc...
http://blogs.sun.com/jmxetc/