users@jersey.java.net

Re: [Jersey] Re: Problem with ContextResolver, generics...

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Wed, 29 Apr 2009 10:35:57 -0700

On Tue, Apr 28, 2009 at 11:42 PM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:
> Hi Tatu,
>
> This is a bug. Could you log an issue?

Will do.

> I have some code ready to fix this, which was incidentally used to determine
> the concrete type from a type variable for the message body readers/writers
> so that they can be ordered by the concrete type. Jersey has some
> implementatons of MessageBodyReader/Wrtier<T> like you want to do for
> ContextResolver<T>.
>
> I have to tell you it was not easy to determine the concrete type from a
> type variable! much head scratching and reflection code to make it work :-)
> something IMHO that should be in the JDK.

Yes, agree 100%. Kohsuke's tiger-types lib helped me understand some
things, but working with generics type info is very challenging; even
just simple things like figuring out raw type-erased class. Not to
mention upper and lower bounds, type class hierarchy being very weird,
having 2 sets of methods (getXxx and getGenericXxx). It's a real pain.
And I only had to deal with subset of cases, to determine generic
Collections, Maps and arrays; but not so much methods (except to
figure out override/masking rules for accessors).

-+ Tatu +-