Leo Sutic wrote:
But the proposed implementation DOES declare and can potentially throw a TooManyListenersException. I don't get the issue here. I must be missing something (seems to be a habbit lately) - please explain.
From: Berin Loritsch [mailto:[EMAIL PROTECTED]]+1
void addLoggerListener( final LoggerListener listener )
throws java.util.TooManyListenersException()
{
if ( null == m_loggerListener )
{
m_loggerListener = listener;
}
else
{
throw new java.util.TooManyListenersException();
}
}
* Easy to do, does not change functionality
* Clearer contract, although it forces client code to do exception
handling for the listener.
* No future API changes other than the removal of the declared
exception Will result in compilation errors. Given a: try { x.addLoggerListener (this); } catch (TooManyListenersException tmle) { // Do nothing } if addLoggerListener (this) doesn't throw a TooManyListenersException, javac will complain that "TooManyListenersException not thrown in corresponding try clause".
Cheers, Steve.
--
Stephen J. McConnell
mailto:[EMAIL PROTECTED]
http://www.osm.net
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]