Fix a regression that expects different type adapters for long.class and Long.class. This is a temporary fix; later we may want to always use the canonical wrapped class.
This commit is contained in:
parent
20d895ff95
commit
c8c3a6965c
|
@ -392,9 +392,8 @@ public final class Gson {
|
|||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T fromJson(String json, Class<T> classOfT) throws JsonParseException {
|
||||
Class<T> wrapped = Primitives.wrap(classOfT);
|
||||
Object object = fromJson(json, (Type) wrapped);
|
||||
return wrapped.cast(object);
|
||||
Object object = fromJson(json, (Type) classOfT);
|
||||
return Primitives.wrap(classOfT).cast(object);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -443,9 +442,8 @@ public final class Gson {
|
|||
* @since 1.2
|
||||
*/
|
||||
public <T> T fromJson(Reader json, Class<T> classOfT) throws JsonParseException {
|
||||
Class<T> wrapped = Primitives.wrap(classOfT);
|
||||
Object object = fromJson(new JsonReader(json), wrapped);
|
||||
return wrapped.cast(object);
|
||||
Object object = fromJson(new JsonReader(json), classOfT);
|
||||
return Primitives.wrap(classOfT).cast(object);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -503,9 +501,8 @@ public final class Gson {
|
|||
* @since 1.3
|
||||
*/
|
||||
public <T> T fromJson(JsonElement json, Class<T> classOfT) throws JsonParseException {
|
||||
Class<T> wrapped = Primitives.wrap(classOfT);
|
||||
Object object = fromJson(json, (Type) wrapped);
|
||||
return wrapped.cast(object);
|
||||
Object object = fromJson(json, (Type) classOfT);
|
||||
return Primitives.wrap(classOfT).cast(object);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user