[jboss-dev] throws Throwable

Tim Fox tim.fox at redhat.com
Thu May 7 11:19:44 EDT 2009


Max Rydahl Andersen wrote:
>
>
> Tim Fox wrote:
>> David M. Lloyd wrote:
>>> On 05/05/2009 03:02 AM, Carlo de Wolf wrote:
>>>> What's the use case for having a public method: doSomething(Object 
>>>> someArgs...) throws Throwable ? 
>>>
>>> No valid use cases exist afaik.  Any method that throws Throwable 
>>> should die, if it's within our power to kill it. 
>> Declaring a method as "throws Throwable" forces the caller to handle 
>> the exception even if the exception/error thrown is unchecked.
> 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?

IMO the whole design or exceptions/errors/throwables in Java is a big 
kludge.
>
> /max
> _______________________________________________
> jboss-development mailing list
> jboss-development at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/jboss-development


-- 
Tim Fox
Messaging Lead
JBoss - a division of Red Hat

http://jbossfox.blogspot.com/

irc.freenode.net#jbossmessaging

fox at redhat.com




More information about the jboss-development mailing list