Re: JSR311: TypeLiteral

From: Dhanji R. Prasanna <>
Date: Wed, 4 Jun 2008 20:14:24 +1000

On Wed, Jun 4, 2008 at 7:39 PM, Stephan Koops <> wrote:

> Hi Paul,
> sorry, I'm not sure if I understand what you want to say (I should use more
> English ...). Do you mean my idea is good or will not work?
> Stephan
> Paul Sandoz wrote:
>> Stephan Koops wrote:
>>> Hi,
>>> what about a generic Response class?
>>> Let's stay at the given example:
>>> public List<Bean> getList() { ... }
>>> could become
>>> public Response<List<Bean>> getList() { ... }
In this example, it is not possible to determine the parameterized type of
the returned object via reflection due to type erasure. You *can* actually
do it by inspecting the method signature, but this is a somewhat unreliable

In other words there is no way to distinguish an object of type
Response.class from Response<List<Bean>>.class (if the latter were valid
syntax). That's where super type-tokens and TypeLiteral can help.