>> Do methods that can potentially throw an Exception (but don't) execute
>> any slower than methods that don't throw Exceptions?
[quoted text clipped - 5 lines]
> when you throw & catch one. That was for fully-compiled code but offhand
> I don't see why it should be too different for an interpretive system.
An O'Reilly benchmark, in the Java Performance Tuning book,
tests the extra cost of putting a try-catch with no exception, in a
loop, instead of around the loop.
This is not a compiler test, it's a vm test. It turns out to be pretty
hard to set up, since any decent (recent) compiler will do a good job of
optimizing your test away.
Most of the VM's tested had a 10% increase in time for having the
try-catch inside the loop, especially those running a JIT.
A much more interesting test in the same chapter, shows that a
conditional instanceof is far more efficient than trying and catching a
ClassCastException.