dev@jsr311.java.net

Re: JSR311: Type erasure and MessageBodyWriter matching

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Thu, 27 Mar 2008 12:59:14 -0400

I follow you but its quite tricky even to get an instance of Type so I
don't know how useful this would be to most developers. Type erasure
is a pain.

Marc.

On Mar 27, 2008, at 12:50 PM, Bill Burke wrote:
> Because of type erasure in Java, you cannot get the types of a
> parameterized generic from an object instance.
>
> I ran into this recently when trying to write a MessageBodyWriter
> for application/x-www-form-urlencoded + MultivaluedMap<String,
> String>. My provider was doing generic type evaluation to determine
> if the returned object was and instance of Multivalued<String,
> String>.
>
> This works great if you match the resource's method's return type.
> You can get the generic type information.
>
> But for Response, it is impossible to get the generic type
> information as you cannot extract it from the
> Response.getEntity().getClass().
>
> I don't know if we need or want a
>
> Response.setEntityGenericType(Type type); method.
>
> Following me?
>
>
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: dev-help_at_jsr311.dev.java.net
>

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