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. :->
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 <[EMAIL PROTECTED]> 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().
--
Chris Gray /k/ Embedded Java Solutions BE0503765045
Embedded & Mobile Java, OSGi http://www.k-embedded-java.com/
[EMAIL PROTECTED] +32 3 216 0369
---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]