diff --git a/android/guava-tests/test/com/google/common/base/AbstractIteratorTest.java b/android/guava-tests/test/com/google/common/base/AbstractIteratorTest.java index 7dc3d0274017..76277dad2c46 100644 --- a/android/guava-tests/test/com/google/common/base/AbstractIteratorTest.java +++ b/android/guava-tests/test/com/google/common/base/AbstractIteratorTest.java @@ -28,6 +28,7 @@ import java.util.Iterator; import java.util.NoSuchElementException; import junit.framework.TestCase; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Unit test for {@code AbstractIterator}. @@ -46,7 +47,7 @@ public void testDefaultBehaviorOfNextAndHasNext() { private int rep; @Override - public Integer computeNext() { + public @Nullable Integer computeNext() { switch (rep++) { case 0: return 0; diff --git a/android/guava-tests/test/com/google/common/base/ToStringHelperTest.java b/android/guava-tests/test/com/google/common/base/ToStringHelperTest.java index c0bf9b25ce76..692a8382ee93 100644 --- a/android/guava-tests/test/com/google/common/base/ToStringHelperTest.java +++ b/android/guava-tests/test/com/google/common/base/ToStringHelperTest.java @@ -28,6 +28,7 @@ import java.util.HashMap; import java.util.Map; import junit.framework.TestCase; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Tests for {@link MoreObjects#toStringHelper(Object)}. @@ -580,7 +581,7 @@ public void testToStringHelperWithArrays() { String[] strings = {"hello", "world"}; int[] ints = {2, 42}; Object[] objects = {"obj"}; - String[] arrayWithNull = {null}; + @Nullable String[] arrayWithNull = new @Nullable String[] {null}; Object[] empty = {}; String toTest = MoreObjects.toStringHelper("TSH") diff --git a/android/guava-tests/test/com/google/common/util/concurrent/FutureCallbackTest.java b/android/guava-tests/test/com/google/common/util/concurrent/FutureCallbackTest.java index df112c169776..3c77ac3b2070 100644 --- a/android/guava-tests/test/com/google/common/util/concurrent/FutureCallbackTest.java +++ b/android/guava-tests/test/com/google/common/util/concurrent/FutureCallbackTest.java @@ -155,10 +155,10 @@ public void onFailure(Throwable t) { public void testWildcardFuture() { SettableFuture settable = SettableFuture.create(); ListenableFuture f = settable; - FutureCallback callback = - new FutureCallback() { + FutureCallback<@Nullable Object> callback = + new FutureCallback<@Nullable Object>() { @Override - public void onSuccess(Object result) {} + public void onSuccess(@Nullable Object result) {} @Override public void onFailure(Throwable t) {} diff --git a/android/guava-tests/test/com/google/common/util/concurrent/TestPlatform.java b/android/guava-tests/test/com/google/common/util/concurrent/TestPlatform.java index 501e52d828d9..91df560584e7 100644 --- a/android/guava-tests/test/com/google/common/util/concurrent/TestPlatform.java +++ b/android/guava-tests/test/com/google/common/util/concurrent/TestPlatform.java @@ -29,6 +29,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.TimeoutException; +import org.checkerframework.checker.nullness.qual.Nullable; /** Methods factored out so that they can be emulated differently in GWT. */ @GwtCompatible(emulated = true) @@ -66,7 +67,8 @@ static void clearInterrupt() { * Retrieves the result of a {@code Future} known to be done but uses the {@code get(long, * TimeUnit)} overload in order to test that method. */ - static V getDoneFromTimeoutOverload(Future future) throws ExecutionException { + static V getDoneFromTimeoutOverload(Future future) + throws ExecutionException { checkState(future.isDone(), "Future was expected to be done: %s", future); try { return getUninterruptibly(future, 0, SECONDS); diff --git a/guava-gwt/test-super/com/google/common/util/concurrent/super/com/google/common/util/concurrent/TestPlatform.java b/guava-gwt/test-super/com/google/common/util/concurrent/super/com/google/common/util/concurrent/TestPlatform.java index 7767869b594c..1cca355bea71 100644 --- a/guava-gwt/test-super/com/google/common/util/concurrent/super/com/google/common/util/concurrent/TestPlatform.java +++ b/guava-gwt/test-super/com/google/common/util/concurrent/super/com/google/common/util/concurrent/TestPlatform.java @@ -24,6 +24,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.TimeoutException; +import org.checkerframework.checker.nullness.qual.Nullable; /** Methods factored out so that they can be emulated differently in GWT. */ final class TestPlatform { @@ -55,7 +56,8 @@ static void clearInterrupt() { // There is no thread interruption in GWT, so there's nothing to do. } - static V getDoneFromTimeoutOverload(Future future) throws ExecutionException { + static V getDoneFromTimeoutOverload(Future future) + throws ExecutionException { checkState(future.isDone(), "Future was expected to be done: %s", future); try { return future.get(0, SECONDS); diff --git a/guava-tests/test/com/google/common/base/AbstractIteratorTest.java b/guava-tests/test/com/google/common/base/AbstractIteratorTest.java index 7dc3d0274017..76277dad2c46 100644 --- a/guava-tests/test/com/google/common/base/AbstractIteratorTest.java +++ b/guava-tests/test/com/google/common/base/AbstractIteratorTest.java @@ -28,6 +28,7 @@ import java.util.Iterator; import java.util.NoSuchElementException; import junit.framework.TestCase; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Unit test for {@code AbstractIterator}. @@ -46,7 +47,7 @@ public void testDefaultBehaviorOfNextAndHasNext() { private int rep; @Override - public Integer computeNext() { + public @Nullable Integer computeNext() { switch (rep++) { case 0: return 0; diff --git a/guava-tests/test/com/google/common/base/ToStringHelperTest.java b/guava-tests/test/com/google/common/base/ToStringHelperTest.java index 21e53d90814f..e8f9eb92eb23 100644 --- a/guava-tests/test/com/google/common/base/ToStringHelperTest.java +++ b/guava-tests/test/com/google/common/base/ToStringHelperTest.java @@ -31,6 +31,7 @@ import java.util.OptionalInt; import java.util.OptionalLong; import junit.framework.TestCase; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Tests for {@link MoreObjects#toStringHelper(Object)}. @@ -591,7 +592,7 @@ public void testToStringHelperWithArrays() { String[] strings = {"hello", "world"}; int[] ints = {2, 42}; Object[] objects = {"obj"}; - String[] arrayWithNull = {null}; + @Nullable String[] arrayWithNull = new @Nullable String[] {null}; Object[] empty = {}; String toTest = MoreObjects.toStringHelper("TSH") diff --git a/guava-tests/test/com/google/common/util/concurrent/FutureCallbackTest.java b/guava-tests/test/com/google/common/util/concurrent/FutureCallbackTest.java index df112c169776..3c77ac3b2070 100644 --- a/guava-tests/test/com/google/common/util/concurrent/FutureCallbackTest.java +++ b/guava-tests/test/com/google/common/util/concurrent/FutureCallbackTest.java @@ -155,10 +155,10 @@ public void onFailure(Throwable t) { public void testWildcardFuture() { SettableFuture settable = SettableFuture.create(); ListenableFuture f = settable; - FutureCallback callback = - new FutureCallback() { + FutureCallback<@Nullable Object> callback = + new FutureCallback<@Nullable Object>() { @Override - public void onSuccess(Object result) {} + public void onSuccess(@Nullable Object result) {} @Override public void onFailure(Throwable t) {} diff --git a/guava-tests/test/com/google/common/util/concurrent/TestPlatform.java b/guava-tests/test/com/google/common/util/concurrent/TestPlatform.java index 501e52d828d9..91df560584e7 100644 --- a/guava-tests/test/com/google/common/util/concurrent/TestPlatform.java +++ b/guava-tests/test/com/google/common/util/concurrent/TestPlatform.java @@ -29,6 +29,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.TimeoutException; +import org.checkerframework.checker.nullness.qual.Nullable; /** Methods factored out so that they can be emulated differently in GWT. */ @GwtCompatible(emulated = true) @@ -66,7 +67,8 @@ static void clearInterrupt() { * Retrieves the result of a {@code Future} known to be done but uses the {@code get(long, * TimeUnit)} overload in order to test that method. */ - static V getDoneFromTimeoutOverload(Future future) throws ExecutionException { + static V getDoneFromTimeoutOverload(Future future) + throws ExecutionException { checkState(future.isDone(), "Future was expected to be done: %s", future); try { return getUninterruptibly(future, 0, SECONDS);