harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Gray <chris.g...@kiffer.be>
Subject Re: [classlib] Exception throwing compatibility
Date Fri, 12 May 2006 09:22:55 GMT
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 <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().

-- 
Chris Gray        /k/ Embedded Java Solutions      BE0503765045
Embedded & Mobile Java, OSGi    http://www.k-embedded-java.com/
chris.gray@kiffer.be                             +32 3 216 0369


---------------------------------------------------------------------
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