Fix warnings

This commit is contained in:
Marcono1234 2020-02-12 19:26:06 +01:00
parent 541252a9fb
commit 361292f1c1
6 changed files with 10 additions and 4 deletions

View File

@ -334,11 +334,11 @@ public final class $Gson$Types {
} }
public static Type resolve(Type context, Class<?> contextRawType, Type toResolve) { public static Type resolve(Type context, Class<?> contextRawType, Type toResolve) {
return resolve(context, contextRawType, toResolve, new HashSet<TypeVariable>()); return resolve(context, contextRawType, toResolve, new HashSet<TypeVariable<?>>());
} }
private static Type resolve(Type context, Class<?> contextRawType, Type toResolve, private static Type resolve(Type context, Class<?> contextRawType, Type toResolve,
Collection<TypeVariable> visitedTypeVariables) { Collection<TypeVariable<?>> visitedTypeVariables) {
// this implementation is made a little more complicated in an attempt to avoid object-creation // this implementation is made a little more complicated in an attempt to avoid object-creation
while (true) { while (true) {
if (toResolve instanceof TypeVariable) { if (toResolve instanceof TypeVariable) {

View File

@ -37,7 +37,6 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive; import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer; import com.google.gson.JsonSerializer;
import com.google.gson.common.MoreAsserts;
import com.google.gson.common.TestTypes.BagOfPrimitives; import com.google.gson.common.TestTypes.BagOfPrimitives;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;

View File

@ -172,6 +172,7 @@ public class TreeTypeAdaptersTest extends TestCase {
int numClasses; int numClasses;
} }
@SafeVarargs
private static <T> List<T> createList(T ...items) { private static <T> List<T> createList(T ...items) {
return Arrays.asList(items); return Arrays.asList(items);
} }

View File

@ -280,6 +280,7 @@ public final class LinkedHashTreeMapTest extends TestCase {
} }
} }
@SafeVarargs
private <T> void assertIterationOrder(Iterable<T> actual, T... expected) { private <T> void assertIterationOrder(Iterable<T> actual, T... expected) {
ArrayList<T> actualList = new ArrayList<T>(); ArrayList<T> actualList = new ArrayList<T>();
for (T t : actual) { for (T t : actual) {

View File

@ -140,6 +140,7 @@ public final class LinkedTreeMapTest extends TestCase {
MoreAsserts.assertEqualsAndHashCode(map1, map2); MoreAsserts.assertEqualsAndHashCode(map1, map2);
} }
@SafeVarargs
private <T> void assertIterationOrder(Iterable<T> actual, T... expected) { private <T> void assertIterationOrder(Iterable<T> actual, T... expected) {
ArrayList<T> actualList = new ArrayList<T>(); ArrayList<T> actualList = new ArrayList<T>();
for (T t : actual) { for (T t : actual) {

View File

@ -36,7 +36,7 @@ public class RecursiveTypesResolveTest extends TestCase {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static class Foo1<A> { private static class Foo1<A> {
public Foo2<? extends A> foo2; public Foo2<? extends A> foo2;
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static class Foo2<B> { private static class Foo2<B> {
@ -48,6 +48,7 @@ public class RecursiveTypesResolveTest extends TestCase {
*/ */
public void testRecursiveResolveSimple() { public void testRecursiveResolveSimple() {
@SuppressWarnings("rawtypes")
TypeAdapter<Foo1> adapter = new Gson().getAdapter(Foo1.class); TypeAdapter<Foo1> adapter = new Gson().getAdapter(Foo1.class);
assertNotNull(adapter); assertNotNull(adapter);
} }
@ -62,6 +63,7 @@ public class RecursiveTypesResolveTest extends TestCase {
} }
public void testIssue440WeakReference() throws Exception { public void testIssue440WeakReference() throws Exception {
@SuppressWarnings("rawtypes")
TypeAdapter<WeakReference> adapter = new Gson().getAdapter(WeakReference.class); TypeAdapter<WeakReference> adapter = new Gson().getAdapter(WeakReference.class);
assertNotNull(adapter); assertNotNull(adapter);
} }
@ -105,11 +107,13 @@ public class RecursiveTypesResolveTest extends TestCase {
} }
public void testRecursiveTypeVariablesResolve1() throws Exception { public void testRecursiveTypeVariablesResolve1() throws Exception {
@SuppressWarnings("rawtypes")
TypeAdapter<TestType> adapter = new Gson().getAdapter(TestType.class); TypeAdapter<TestType> adapter = new Gson().getAdapter(TestType.class);
assertNotNull(adapter); assertNotNull(adapter);
} }
public void testRecursiveTypeVariablesResolve12() throws Exception { public void testRecursiveTypeVariablesResolve12() throws Exception {
@SuppressWarnings("rawtypes")
TypeAdapter<TestType2> adapter = new Gson().getAdapter(TestType2.class); TypeAdapter<TestType2> adapter = new Gson().getAdapter(TestType2.class);
assertNotNull(adapter); assertNotNull(adapter);
} }