On Apr 14, 2010, at 11:31 AM, Laird Nelson wrote:
> I wonder if someone would be kind enough to talk more about the
> java.lang.reflect.Type argument in, say, the writeTo() method of
> MessageBodyWriter (see
> http://java.sun.com/javaee/6/docs/api/javax/ws/rs/ext/MessageBodyWriter.html#writeTo%28T,%20java.lang.Class,%20java.lang.reflect.Type,%20java.lang.annotation.Annotation[],%20javax.ws.rs.core.MediaType,%20javax.ws.rs.core.MultivaluedMap,%20java.io.OutputStream%29
> for details).
>
> From staring at the Javadoc, I don't see how it differs from the
> java.lang.Class argument. I mean, I know how java.lang.reflect.Type
> differs from java.lang.Class, but I don't understand the origin of
> this parameter, or whether it's always required, or whether it might
> be null, or whether I'm obliged to consider it, or all of those other
> contractual details that aren't spelled out in the, er, contract. :-)
>
Type gives more information that Class. E.g. the class of List<String> is List.class, you need the Type to determine that its actually a list of strings. In many cases you probably won't care about the difference, its provided for those cases where you do care.
Marc.