Anton Avtamonov wrote:
On 4/25/06, Dmitry M. Kononov <[EMAIL PROTECTED]> wrote:
On 4/25/06, Tim Ellison <[EMAIL PROTECTED]> wrote:
Jimmy, Jing Lv wrote:
I agree.
But there are at least two exceptional situation:
1) several exceptions throws from one method, which extend one parent
class, e.g. ConnectionException and UnknownHostException, javadoc writes
"throws IOException" rather than "throws
ConnectionException,UnknownHostException". And in implementation, we
shall throw them out directly instead of
try{...
}catch(UnknownHostException e){
    throw new IOException();
}
catch(ConnectionException e){
    throw new IOException();
}
right? :)
+1, and other instances where super-types or super-interfaces declare
compatible throws clauses that are implemented in subclasses that throw
more specific subtypes.  I do not agree that we should be bound to throw
and exception of the identical type as the declaration.
If we want to follow the spec and if we want to restrain ourself from
"improving" the spec, I think we really need to throw IOException. If
this exception can be caused by different ways we apparently have to
throw IOException with an appropriate cause.

From the general perspective, in the example above re-throwing
IOException looks quite ugly. Besides, it hides some important
information (since Java uses exception sub-classing to represent the
particular type of problem). However we are not free with design, I
think. Could someone please remind me an idea: for the example above
do we mean that the spec states IOException and RI throws exactly
IOException (I traversed the thread, but still not sure what was
meant)?

For the example 1) I mean the spec usually merge several exceptions into one parent exception. In this situation, commonly RI throws child exception itself, although it is hard to tell what RI exactly throw in some special situation. And I think we are not "improving" the spec if we throw child exceptions, it is just convention or something writing "throws IOException" instead of writing "throws connectionException, UnknownHostException". We do follow spec if we throw child exception.

The idea behind the question is: why not just copy RI in this case
(conforming Tim's guidelines)?


Yes,I firmly agree with Tim's guidelines. We should first follow spec and then RI. In this case, we still follow the spec, right? :)

--
Anton Avtamonov,
Intel Middleware Products Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--

Best Regards!

Jimmy, Jing Lv
China Software Development Lab, IBM

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to