[jboss-dev] throws Throwable

Max Rydahl Andersen max.andersen at redhat.com
Thu May 7 13:42:07 EDT 2009


>> Then do throws RuntimeException
>>
>> Error's are *nonrecoverable* since they are OutOfMemory or hard VM 
>> errors.No client can ever recover sanely. 
> Hmm if Error's are not supposed to be caught, it begs the question why 
> does Java throw them in the first place? It's a tease "Haha I'm going 
> to throw this error, you can watch it but you're not allowed to catch 
> it!!". If they're really supposed to be uncoverable why doesn't it 
> just make the JVM exit?
I did not say noone should catch them, just that no client can recover 
sanely (besides panic logging and resource cleanup with a quick rethrow 
or hard exit, meaning no API should require catch Throwable.

> IMO the whole design or exceptions/errors/throwables in Java is a big 
> kludge.
What I like about "throws ..." is that it is possible to see what 
methods throws the exception, what I don't like is that you are 
*required* to catch them.

/max



More information about the jboss-development mailing list