harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jimmy, Jing Lv" <firep...@gmail.com>
Subject Re: [classlib] matching RI exceptions -- are we required to have this type of compatibility?
Date Tue, 25 Apr 2006 10:04:36 GMT
Anton Avtamonov wrote:
> On 4/25/06, Dmitry M. Kononov <dmitry.m.kononov@gmail.com> wrote:
>> On 4/25/06, Tim Ellison <t.p.ellison@gmail.com> 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: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> 
> 


-- 

Best Regards!

Jimmy, Jing Lv
China Software Development Lab, IBM

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Mime
View raw message