diff --git a/android/guava-testlib/src/com/google/common/testing/ArbitraryInstances.java b/android/guava-testlib/src/com/google/common/testing/ArbitraryInstances.java index a52373d64976..c47ea9113f17 100644 --- a/android/guava-testlib/src/com/google/common/testing/ArbitraryInstances.java +++ b/android/guava-testlib/src/com/google/common/testing/ArbitraryInstances.java @@ -17,6 +17,7 @@ package com.google.common.testing; import static com.google.common.base.Preconditions.checkArgument; +import static java.util.Objects.requireNonNull; import com.google.common.annotations.GwtIncompatible; import com.google.common.annotations.J2ktIncompatible; @@ -410,7 +411,8 @@ private static void setImplementation(Class type, Class impl } private static T createEmptyArray(Class arrayType) { - return arrayType.cast(Array.newInstance(arrayType.getComponentType(), 0)); + // getComponentType() is non-null because we call createEmptyArray only with an array type. + return arrayType.cast(Array.newInstance(requireNonNull(arrayType.getComponentType()), 0)); } // Internal implementations of some classes, with public default constructor that get() needs. diff --git a/android/guava/src/com/google/common/util/concurrent/InterruptibleTask.java b/android/guava/src/com/google/common/util/concurrent/InterruptibleTask.java index 6f33c5032da5..effa8ef59bab 100644 --- a/android/guava/src/com/google/common/util/concurrent/InterruptibleTask.java +++ b/android/guava/src/com/google/common/util/concurrent/InterruptibleTask.java @@ -23,6 +23,7 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.locks.AbstractOwnableSynchronizer; import java.util.concurrent.locks.LockSupport; +import javax.annotation.CheckForNull; import org.checkerframework.checker.nullness.qual.Nullable; @GwtCompatible(emulated = true) @@ -234,6 +235,7 @@ private void setOwner(Thread thread) { } @VisibleForTesting + @CheckForNull Thread getOwner() { return super.getExclusiveOwnerThread(); } diff --git a/guava-testlib/src/com/google/common/testing/ArbitraryInstances.java b/guava-testlib/src/com/google/common/testing/ArbitraryInstances.java index 0071feacf434..9e4ab85febde 100644 --- a/guava-testlib/src/com/google/common/testing/ArbitraryInstances.java +++ b/guava-testlib/src/com/google/common/testing/ArbitraryInstances.java @@ -17,6 +17,7 @@ package com.google.common.testing; import static com.google.common.base.Preconditions.checkArgument; +import static java.util.Objects.requireNonNull; import com.google.common.annotations.GwtIncompatible; import com.google.common.annotations.J2ktIncompatible; @@ -422,7 +423,8 @@ private static void setImplementation(Class type, Class impl } private static T createEmptyArray(Class arrayType) { - return arrayType.cast(Array.newInstance(arrayType.getComponentType(), 0)); + // getComponentType() is non-null because we call createEmptyArray only with an array type. + return arrayType.cast(Array.newInstance(requireNonNull(arrayType.getComponentType()), 0)); } // Internal implementations of some classes, with public default constructor that get() needs. diff --git a/guava/src/com/google/common/util/concurrent/InterruptibleTask.java b/guava/src/com/google/common/util/concurrent/InterruptibleTask.java index 6f33c5032da5..effa8ef59bab 100644 --- a/guava/src/com/google/common/util/concurrent/InterruptibleTask.java +++ b/guava/src/com/google/common/util/concurrent/InterruptibleTask.java @@ -23,6 +23,7 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.locks.AbstractOwnableSynchronizer; import java.util.concurrent.locks.LockSupport; +import javax.annotation.CheckForNull; import org.checkerframework.checker.nullness.qual.Nullable; @GwtCompatible(emulated = true) @@ -234,6 +235,7 @@ private void setOwner(Thread thread) { } @VisibleForTesting + @CheckForNull Thread getOwner() { return super.getExclusiveOwnerThread(); }