From 18336d0f8cf2c758d482adfe8c56731515afc6ec Mon Sep 17 00:00:00 2001 From: maicolAntali Date: Sat, 18 Feb 2023 14:06:12 +0100 Subject: [PATCH 01/55] Adds `@SuppressWarnings("NarrowingCompoundAssignment")` --- gson/src/main/java/com/google/gson/stream/JsonReader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gson/src/main/java/com/google/gson/stream/JsonReader.java b/gson/src/main/java/com/google/gson/stream/JsonReader.java index 718a7c2a8c..3f853d8e25 100644 --- a/gson/src/main/java/com/google/gson/stream/JsonReader.java +++ b/gson/src/main/java/com/google/gson/stream/JsonReader.java @@ -1590,7 +1590,7 @@ public String getPath() { * @throws NumberFormatException if any unicode escape sequences are * malformed. */ - @SuppressWarnings("fallthrough") + @SuppressWarnings({"fallthrough", "NarrowingCompoundAssignment"}) private char readEscapeCharacter() throws IOException { if (pos == limit && !fillBuffer(1)) { throw syntaxError("Unterminated escape sequence"); From 0c2f8c304ea840e7f40e69c4940b3a546644c901 Mon Sep 17 00:00:00 2001 From: maicolAntali Date: Sat, 18 Feb 2023 14:06:21 +0100 Subject: [PATCH 02/55] Adds `@SuppressWarnings("TypeParameterUnusedInFormals")` --- gson/src/main/java/com/google/gson/Gson.java | 8 ++++---- .../java/com/google/gson/JsonDeserializationContext.java | 1 + .../com/google/gson/internal/bind/TreeTypeAdapter.java | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/gson/src/main/java/com/google/gson/Gson.java b/gson/src/main/java/com/google/gson/Gson.java index 054b1f92ed..45336a87e9 100644 --- a/gson/src/main/java/com/google/gson/Gson.java +++ b/gson/src/main/java/com/google/gson/Gson.java @@ -1011,7 +1011,7 @@ public T fromJson(String json, Class classOfT) throws JsonSyntaxException * @see #fromJson(String, Class) * @see #fromJson(String, TypeToken) */ - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"}) public T fromJson(String json, Type typeOfT) throws JsonSyntaxException { return (T) fromJson(json, TypeToken.get(typeOfT)); } @@ -1104,7 +1104,7 @@ public T fromJson(Reader json, Class classOfT) throws JsonSyntaxException * @see #fromJson(Reader, Class) * @see #fromJson(Reader, TypeToken) */ - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"}) public T fromJson(Reader json, Type typeOfT) throws JsonIOException, JsonSyntaxException { return (T) fromJson(json, TypeToken.get(typeOfT)); } @@ -1183,7 +1183,7 @@ private static void assertFullConsumption(Object obj, JsonReader reader) { * @see #fromJson(Reader, Type) * @see #fromJson(JsonReader, TypeToken) */ - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"}) public T fromJson(JsonReader reader, Type typeOfT) throws JsonIOException, JsonSyntaxException { return (T) fromJson(reader, TypeToken.get(typeOfT)); } @@ -1297,7 +1297,7 @@ public T fromJson(JsonElement json, Class classOfT) throws JsonSyntaxExce * @see #fromJson(JsonElement, Class) * @see #fromJson(JsonElement, TypeToken) */ - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"}) public T fromJson(JsonElement json, Type typeOfT) throws JsonSyntaxException { return (T) fromJson(json, TypeToken.get(typeOfT)); } diff --git a/gson/src/main/java/com/google/gson/JsonDeserializationContext.java b/gson/src/main/java/com/google/gson/JsonDeserializationContext.java index 00c7505432..093653d90f 100644 --- a/gson/src/main/java/com/google/gson/JsonDeserializationContext.java +++ b/gson/src/main/java/com/google/gson/JsonDeserializationContext.java @@ -40,5 +40,6 @@ public interface JsonDeserializationContext { * @return An object of type typeOfT. * @throws JsonParseException if the parse tree does not contain expected data. */ + @SuppressWarnings("TypeParameterUnusedInFormals") public T deserialize(JsonElement json, Type typeOfT) throws JsonParseException; } \ No newline at end of file diff --git a/gson/src/main/java/com/google/gson/internal/bind/TreeTypeAdapter.java b/gson/src/main/java/com/google/gson/internal/bind/TreeTypeAdapter.java index 47ca8fc03a..a1a5f760d4 100644 --- a/gson/src/main/java/com/google/gson/internal/bind/TreeTypeAdapter.java +++ b/gson/src/main/java/com/google/gson/internal/bind/TreeTypeAdapter.java @@ -174,8 +174,9 @@ private final class GsonContextImpl implements JsonSerializationContext, JsonDes @Override public JsonElement serialize(Object src, Type typeOfSrc) { return gson.toJsonTree(src, typeOfSrc); } - @SuppressWarnings("unchecked") - @Override public R deserialize(JsonElement json, Type typeOfT) throws JsonParseException { + @Override + @SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"}) + public R deserialize(JsonElement json, Type typeOfT) throws JsonParseException { return gson.fromJson(json, typeOfT); } } From 7f64bf33fb10568e264900b4ff614117aed8e864 Mon Sep 17 00:00:00 2001 From: maicolAntali Date: Sat, 18 Feb 2023 14:09:15 +0100 Subject: [PATCH 03/55] Adds `@SuppressWarnings("JavaUtilDate")` --- .../java/com/google/gson/internal/sql/SqlDateTypeAdapter.java | 1 + .../java/com/google/gson/internal/sql/SqlTimeTypeAdapter.java | 1 + .../com/google/gson/internal/sql/SqlTimestampTypeAdapter.java | 1 + .../main/java/com/google/gson/internal/sql/SqlTypesSupport.java | 1 + 4 files changed, 4 insertions(+) diff --git a/gson/src/main/java/com/google/gson/internal/sql/SqlDateTypeAdapter.java b/gson/src/main/java/com/google/gson/internal/sql/SqlDateTypeAdapter.java index 6ae4c3ef50..271f23c21c 100644 --- a/gson/src/main/java/com/google/gson/internal/sql/SqlDateTypeAdapter.java +++ b/gson/src/main/java/com/google/gson/internal/sql/SqlDateTypeAdapter.java @@ -36,6 +36,7 @@ * this class state. DateFormat isn't thread safe either, so this class has * to synchronize its read and write methods. */ +@SuppressWarnings("JavaUtilDate") final class SqlDateTypeAdapter extends TypeAdapter { static final TypeAdapterFactory FACTORY = new TypeAdapterFactory() { @SuppressWarnings("unchecked") // we use a runtime check to make sure the 'T's equal diff --git a/gson/src/main/java/com/google/gson/internal/sql/SqlTimeTypeAdapter.java b/gson/src/main/java/com/google/gson/internal/sql/SqlTimeTypeAdapter.java index c2a37073f0..ac327ff16f 100644 --- a/gson/src/main/java/com/google/gson/internal/sql/SqlTimeTypeAdapter.java +++ b/gson/src/main/java/com/google/gson/internal/sql/SqlTimeTypeAdapter.java @@ -37,6 +37,7 @@ * this class state. DateFormat isn't thread safe either, so this class has * to synchronize its read and write methods. */ +@SuppressWarnings("JavaUtilDate") final class SqlTimeTypeAdapter extends TypeAdapter