diff --git a/android/guava/src/com/google/common/collect/ObjectArrays.java b/android/guava/src/com/google/common/collect/ObjectArrays.java index 0f928e170275..309572afd5af 100644 --- a/android/guava/src/com/google/common/collect/ObjectArrays.java +++ b/android/guava/src/com/google/common/collect/ObjectArrays.java @@ -25,6 +25,7 @@ import java.util.Arrays; import java.util.Collection; import javax.annotation.CheckForNull; +import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; /** @@ -35,6 +36,7 @@ */ @GwtCompatible(emulated = true) @ElementTypesAreNonnullByDefault +@SuppressWarnings("AvoidObjectArrays") public final class ObjectArrays { private ObjectArrays() {} @@ -47,7 +49,7 @@ private ObjectArrays() {} */ @GwtIncompatible // Array.newInstance(Class, int) @SuppressWarnings("unchecked") - public static T[] newArray(Class type, int length) { + public static T[] newArray(Class<@NonNull T> type, int length) { return (T[]) Array.newInstance(type, length); } @@ -69,7 +71,8 @@ public static T[] newArray(Class type, int length) { * @param type the component type of the returned array */ @GwtIncompatible // Array.newInstance(Class, int) - public static T[] concat(T[] first, T[] second, Class type) { + public static T[] concat( + T[] first, T[] second, Class<@NonNull T> type) { T[] result = newArray(type, first.length + second.length); System.arraycopy(first, 0, result, 0, first.length); System.arraycopy(second, 0, result, first.length, second.length); diff --git a/guava/src/com/google/common/collect/ObjectArrays.java b/guava/src/com/google/common/collect/ObjectArrays.java index d3b048da7e45..1a2df3b3e787 100644 --- a/guava/src/com/google/common/collect/ObjectArrays.java +++ b/guava/src/com/google/common/collect/ObjectArrays.java @@ -24,6 +24,7 @@ import java.lang.reflect.Array; import java.util.Arrays; import java.util.Collection; +import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; /** @@ -34,6 +35,7 @@ */ @GwtCompatible(emulated = true) @ElementTypesAreNonnullByDefault +@SuppressWarnings("AvoidObjectArrays") public final class ObjectArrays { private ObjectArrays() {} @@ -46,7 +48,7 @@ private ObjectArrays() {} */ @GwtIncompatible // Array.newInstance(Class, int) @SuppressWarnings("unchecked") - public static T[] newArray(Class type, int length) { + public static T[] newArray(Class<@NonNull T> type, int length) { return (T[]) Array.newInstance(type, length); } @@ -68,7 +70,8 @@ public static T[] newArray(Class type, int length) { * @param type the component type of the returned array */ @GwtIncompatible // Array.newInstance(Class, int) - public static T[] concat(T[] first, T[] second, Class type) { + public static T[] concat( + T[] first, T[] second, Class<@NonNull T> type) { T[] result = newArray(type, first.length + second.length); System.arraycopy(first, 0, result, 0, first.length); System.arraycopy(second, 0, result, first.length, second.length);