From 5d31558428466ebe531a1255271dfc6b800f36a0 Mon Sep 17 00:00:00 2001 From: Inderjeet Singh Date: Wed, 25 May 2011 16:13:36 +0000 Subject: [PATCH] eliminated maven compilation problems with JDK 5 --- .../google/gson/JsonDeserializationContext.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gson/src/main/java/com/google/gson/JsonDeserializationContext.java b/gson/src/main/java/com/google/gson/JsonDeserializationContext.java index c6e3cefe..111bc1cb 100644 --- a/gson/src/main/java/com/google/gson/JsonDeserializationContext.java +++ b/gson/src/main/java/com/google/gson/JsonDeserializationContext.java @@ -43,8 +43,10 @@ public final class JsonDeserializationContext { } + @SuppressWarnings("unchecked") public T construct(Type type) { - return objectConstructor.construct(type); + Object instance = objectConstructor.construct(type); + return (T) instance; } public Object constructArray(Type type, int length) { @@ -92,15 +94,19 @@ public final class JsonDeserializationContext { * @return An object of type typeOfT. * @throws JsonParseException if the parse tree does not contain expected data. */ + @SuppressWarnings("unchecked") public T deserialize(JsonElement json, Type typeOfT) throws JsonParseException { if (json == null || json.isJsonNull()) { return null; } else if (json.isJsonArray()) { - return fromJsonArray(typeOfT, json.getAsJsonArray(), this); + Object array = fromJsonArray(typeOfT, json.getAsJsonArray(), this); + return (T) array; } else if (json.isJsonObject()) { - return fromJsonObject(typeOfT, json.getAsJsonObject(), this); + Object object = fromJsonObject(typeOfT, json.getAsJsonObject(), this); + return (T) object; } else if (json.isJsonPrimitive()) { - return fromJsonPrimitive(typeOfT, json.getAsJsonPrimitive(), this); + Object primitive = fromJsonPrimitive(typeOfT, json.getAsJsonPrimitive(), this); + return (T) primitive; } else { throw new JsonParseException("Failed parsing JSON source: " + json + " to Json"); }