users@jersey.java.net

Re: Type argument in MessageBodyWriter methods

From: ljnelson <ljnelson_at_gmail.com>
Date: Wed, 14 Apr 2010 14:13:13 -0800 (PST)

On Wed, Apr 14, 2010 at 5:39 PM, Marc Hadley-2 [via Jersey]
<ml-node+4904290-438582279-210534_at_n2.nabble.com> wrote:
> Generics can be mind boggling. I don't know the correct incantation to fix
> this but if you change the above line to
>
> final MessageBodyWriter delegate = ...
>
> Then the compiler is happy.

Well, I still get warnings, of course, because now I'm simply hiding
the API problem by using a raw type.

I think the problem is still with the API in this particular case.
The delegate I get back simply can't be guaranteed to be able to take
Ts, in other words. I'm shoving a T at it, of course, and the
compiler is letting me do this, but the delegate I got back might not
be able to handle Ts.

(If you think I'm wrong, then the signature for
Providers#getMessageBodyWriter() needs to change to prevent what I
just did.)

If the proper answer here is, instead, the only way to make this work
as guaranteed by the specification is to use a raw type, then, OK, so
be it, but that probably means there's an assumption still being made
somewhere about types.

Respectfully,
Laird

-- 
View this message in context: http://n2.nabble.com/Type-argument-in-MessageBodyWriter-methods-tp4902440p4904433.html
Sent from the Jersey mailing list archive at Nabble.com.