users@jsr311.java.net

Re: Questions on Providers interface

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Thu, 21 Aug 2008 15:13:54 -0400

On Aug 21, 2008, at 10:16 AM, Reto Bachmann-Gmür wrote:

> The interface Providers declares:
>
> <T> ExceptionMapper<T> getExceptionMapper(java.lang.Class<T> type)
>
> 1. Why isn't T declared to extend Exceptions or Throwable?

IIRC we did discuss this a while ago but never settled on an answer.
Strictly speaking I guess it should be:

public interface ExceptionMapper<E extends Throwable> {...}

and

<T extends Throwable> ExceptionMapper<T> getExceptionMapper(Class<T>
type);

> 2. If I understand things right the method may return the
> ExceptionMapper for a superclass of type, so shouldn't either the
> return value be ExceptionMapper<? super T> or the argument Class<?
> extends T> type?
>
I don't think that is really necessary. An ExceptionMapper<Exception>
will handle Exception or any subclass so changing the signature to:

<T extends Throwable> ExceptionMapper<? super T>
getExceptionMapper(Class<T> type);

just makes the signature look more complex without adding any real
value.

Marc.

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