jsr343-experts@jms-spec.java.net

[jsr343-experts] Re: [jms-spec users] (JMS_SPEC-35) Remove the use of unchecked exceptions from the JMS API as far as possible

From: Graham Wallis <graham_wallis_at_uk.ibm.com>
Date: Mon, 1 Aug 2011 11:27:56 +0100

Nigel Deakin <nigel.deakin_at_oracle.com> wrote on 29/07/2011 18:37:24:

> From: Nigel Deakin <nigel.deakin_at_oracle.com>
> To: jsr343-experts_at_jms-spec.java.net
> Date: 29/07/2011 18:38
> Subject: [jms-spec users] [jsr343-experts] (JMS_SPEC-35) Remove the
> use of unchecked exceptions from the JMS API as far as possible
>
> This issue was raised by Reza as one of his initial priorities, and
> although this would help the development of
> frameworks that use JMS it also stands alone as a possible
> improvement. I've therefore logged it as an issue in its own
> right in JIRA.
>
> I'm conscious this might be an incompatible change which we would
> need to consider carefully. Comments please, both on
> whether you think this is desirable in principle and whether you
> think it is practical to make as a change in JMS 2.0.

In terms of desirability - yes I would be keen to see this introduced.

In terms of practicality I think we have to be careful, because it won't be
possible to mix JMS 1.1 and JMS 2.0 behaviour/code in the same module due
to the change in inheritance. That's not a show-stopper, but we should
attempt to provide guidance on migration for developers of apps and
providers.

> Also, if you would like to suggest alternative ways of achieving the
> same result (e.g. a completely new API) then please
> say so.
>
> http://java.net/jira/browse/JMS_SPEC-35
>
> "In JMS 1.1, almost every method in the JMS API throws a
> javax.jms.Exception, which is an unchecked exception and so
> needs to be caught and handled by the application.
>
> "In practice the developer rarely knows what to do in such
> circumstances, and provides some generic exception handling
> that is not specific to {{JMSException}}s. The result is to clutter
> the application code with boilerplate exception
> handling which adds little value.
>
> "In addition, the fact that so many API methods throw this checked
> exception makes it more difficult to construct
> frameworks on top of the JMS API.
>
> "It is therefore proposed that the JSR 343 Expert Group consider
> whether they should change the JMS API to throw
> unchecked rather than checked exceptions as much as possible. One
> simple way of achieving this would be to change
> {{javax.jms.JMSException}} to extend {{java.lang.RuntimeException}}
> instead of {{java.lang.Exception}}.
>
> "Existing applications which explicitly catch {JMSException}}s would
> not need to be changed. "
>
> Nigel
>
>