ChineSouad / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

Avoid compiler warnings when deserializing to a parameterized type #248

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Foo<Bar> foo = gson.fromJson(json, Foo.class);

currently produces compiler warning for unchecked conversion and needs 
@SuppressWarnings("unchecked")

Explore revising gson.fromJson(String json, Class<? super T> classOfT) to get 
rid of this warning.

Original issue reported on code.google.com by inder123 on 5 Oct 2010 at 1:53

GoogleCodeExporter commented 9 years ago
There's nothing we can do here. The type of List.class is Class<List>, not the 
type we really want. The only typesafe option we have is to add an overload 
that accepts a TypeToken, and we've already decided not to go that route.

Original comment by limpbizkit on 3 Nov 2010 at 3:19

GoogleCodeExporter commented 9 years ago
There's nothing we can do here. The type of List.class is Class<List>, not the 
type we really want. The only typesafe option we have is to add an overload 
that accepts a TypeToken, and we've already decided not to go that route.

Original comment by limpbizkit on 3 Nov 2010 at 3:19