dev@jsr311.java.net

Re: JSR311: exception mapping of wrapper exceptions

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Thu, 26 Jun 2008 09:15:18 -0400

On Jun 26, 2008, at 3:50 AM, Paul Sandoz wrote:

>
> On Jun 26, 2008, at 9:12 AM, Paul Sandoz wrote:
>
>>>
>>> Also I think that, strictly speaking, getExceptionMapper should
>>> return ExceptionMapper<? super T> rather than ExceptionMapper<T>
>>> since getExceptionMapper(FooException.class) could actually return
>>> an ExcpetionMapper<Exception.class> if that is provider whose
>>> generic type is the nearest superclass of Foo. Not sure it
>>> particularly matters though, is it worth being explicit ?
>>>
>>
>> I think it is worth using the type system where possible to be more
>> accurate.
>>
>
> From the advice of Josh Bloch using wildcards should be avoided for
> return types because it makes things hard and exposes such things on
> the user (namely they start having to declare the wildcard type)
> where as wildcards should be used to accept or reject things.
>
That makes sense, I'll stick with <T> then.

Marc.

---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.