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] Exception throwing compatibility
Date Fri, 12 May 2006 09:33:10 GMT
 > Chris Gray wrote:
> More generally, from a performance point of view it is best not to write
>   if (index < 0 || index >= array.length || etc. etc.) {
>     throw new FooIndexOutOfBoundsException();
>   }
> if there is a method call or an array access which will throw the exception 
> anyway. (Many null parameter checks can be omitted for the same reason). 
> Looks like Sun have followed this policy, and dealt with the not-quite-right 
> exception type by fudging the spec to throw the common supertype. :-> 

That hits the point. What RI throws is natural, just because they write 
that way. However we will never know what RI writes, we just implement 
the spec in our way, that's why there are many
        throw new exception();
        throw new exception();
in Harmony.

After all, our mission is to make it compatible, right? :)

> Chris
> On Friday 12 May 2006 09:11, Mikhail Fursov wrote:
>> Note that this is not only "beautiful" but also performance oriented way ->
>> do not create extra rethrows if it's possible
>> On 5/12/06, Semukhina, Elena V <elena.v.semukhina@intel.com> wrote:
>>> To have a "beautiful" fix, why don't you just write
>>> System.arraycopy(data, start, value, 0, count);
>>> without trying to catch any exception and rethrow another one?
>>> ArrayIndexOutOfBoundsException, if happened, would be thrown by
>>> System.arraycopy().


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

View raw message