Re: Exceptions no longer incur overhead?
- From: Tom Hawtin <usenet@xxxxxxxxxxxxxxxxx>
- Date: Fri, 29 Jun 2007 23:50:45 +0100
void.no.spam.com@xxxxxxxxx wrote:
One of our classes has a method to look up an object. If the object
does not exist, it throws an exception to indicate that. I thought it
would be better to just return null, as exceptions incur overhead. I
talked to the senior java developer who wrote the class, and he said
that recent versions of Java have improved exceptions to the point
that they do not really incur any overhead. Is this true?
In some circumstances exceptions *throws* can be optimised away. Explicitly creating an exception, however, is expensive. Mostly in creating the stack trace.
Anyway, the general approach is to write code to be well written. Then test performance in real world situations.
Tom Hawtin
.
- References:
- Exceptions no longer incur overhead?
- From: void.no.spam.com@xxxxxxxxx
- Exceptions no longer incur overhead?
- Prev by Date: Re: Exceptions no longer incur overhead?
- Next by Date: Re: Exceptions no longer incur overhead?
- Previous by thread: Re: Exceptions no longer incur overhead?
- Next by thread: Re: Exceptions no longer incur overhead?
- Index(es):