Skip to content

Commit d997ad9

Browse files
cpovirkGoogle Java Core Libraries
authored and
Google Java Core Libraries
committedDec 21, 2024·
Migrate from @CheckForNull to Checker Framework @Nullable.
A future step will migrate from these and our already existing usages of the Checker Framework `@Nullable` to the JSpecify `@Nullable`. This is the next step toward [using JSpecify in Guava](jspecify/jspecify#239 (comment)). RELNOTES=Migrated from `@CheckForNull` to Checker Framework `@Nullable`. Most tools recognize both annotations, so we expect this to be a no-op in almost all cases. PiperOrigin-RevId: 708617636
1 parent ae36f57 commit d997ad9

File tree

673 files changed

+4710
-6770
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

673 files changed

+4710
-6770
lines changed
 

Diff for: ‎android/guava-testlib/src/com/google/common/testing/ClassSanityTester.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
import java.util.List;
5151
import java.util.Map.Entry;
5252
import java.util.Set;
53-
import javax.annotation.CheckForNull;
5453
import junit.framework.Assert;
5554
import junit.framework.AssertionFailedError;
5655
import org.jspecify.annotations.NullUnmarked;
@@ -657,8 +656,7 @@ private FreshValueGenerator newFreshValueGenerator() {
657656
FreshValueGenerator generator =
658657
new FreshValueGenerator() {
659658
@Override
660-
@CheckForNull
661-
Object interfaceMethodCalled(Class<?> interfaceType, Method method) {
659+
@Nullable Object interfaceMethodCalled(Class<?> interfaceType, Method method) {
662660
return getDummyValue(TypeToken.of(interfaceType).method(method).getReturnType());
663661
}
664662
};
@@ -737,8 +735,7 @@ private List<Object> getDummyArguments(Invokable<?, ?> invokable)
737735
return args;
738736
}
739737

740-
@CheckForNull
741-
private <T> T getDummyValue(TypeToken<T> type) {
738+
private <T> @Nullable T getDummyValue(TypeToken<T> type) {
742739
Class<? super T> rawType = type.getRawType();
743740
@SuppressWarnings("unchecked") // Assume all default values are generics safe.
744741
T defaultValue = (T) defaultValues.getInstance(rawType);

Diff for: ‎android/guava-testlib/src/com/google/common/testing/FreshValueGenerator.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@
120120
import java.util.concurrent.ConcurrentMap;
121121
import java.util.concurrent.atomic.AtomicInteger;
122122
import java.util.regex.Pattern;
123-
import javax.annotation.CheckForNull;
124123
import org.jspecify.annotations.NullUnmarked;
125124
import org.checkerframework.checker.nullness.qual.Nullable;
126125

@@ -294,8 +293,8 @@ private final class FreshInvocationHandler extends AbstractInvocationHandler {
294293
}
295294

296295
@Override
297-
@CheckForNull
298-
protected Object handleInvocation(Object proxy, Method method, @Nullable Object[] args) {
296+
protected @Nullable Object handleInvocation(
297+
Object proxy, Method method, @Nullable Object[] args) {
299298
return interfaceMethodCalled(interfaceType, method);
300299
}
301300

@@ -320,8 +319,7 @@ public String toString() {
320319
}
321320

322321
/** Subclasses can override to provide different return value for proxied interface methods. */
323-
@CheckForNull
324-
Object interfaceMethodCalled(Class<?> interfaceType, Method method) {
322+
@Nullable Object interfaceMethodCalled(Class<?> interfaceType, Method method) {
325323
throw new UnsupportedOperationException();
326324
}
327325

0 commit comments

Comments
 (0)
Please sign in to comment.