abdulrehmanz / google-gson

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

Improve JsonDeserializationContext type safety #448

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Foo foo = ctx.deserialize(jsonElement, Bar.class);

JsonDeserializationContext have the method
<T> T deserialize(JsonElement json, Type typeOfT)

You may accidentally pass wrong typeOfT argument here and it'll explode at 
runtime (Bar do not extend Foo).

Why not make it type safer and make compiler catch the problem:
<T> T deserialize(JsonElement json, TypeToken<T> typeOfT)
<T> T deserialize(JsonElement json, Class<T> typeOfT)

Original issue reported on code.google.com by Ash2kk@gmail.com on 30 May 2012 at 10:08

GoogleCodeExporter commented 9 years ago
Acknowledged. Unfortunately it's too late to address this. We're encouraging 
use of our new TypeAdapter APIs which are type safe in this way.

Original comment by limpbizkit on 30 Jun 2012 at 2:43