aboutsummaryrefslogtreecommitdiff
path: root/android/guava-testlib/src/com/google/common
diff options
context:
space:
mode:
authorcpovirk <cpovirk@google.com>2021-04-05 13:52:13 -0700
committerGoogle Java Core Libraries <java-core-libraries-team+copybara@google.com>2021-04-05 13:54:57 -0700
commita6489b698173d00ce4d3106642705e2c460eb00a (patch)
tree9fced7ea6abd69925040d4d59510c74ae776ae5d /android/guava-testlib/src/com/google/common
parent77351571c97870a3f4caadb9ee689724b46e4c91 (diff)
downloadguava-a6489b698173d00ce4d3106642705e2c460eb00a.tar.gz
Recognize `@ParametricNullness` in `NullPointerTester`.
In short: Take a method parameter whose type is a type-variable usage `T`. `NullPointerTester` assumed that the method should throw an exception when passed `null` unless the parameter type is annotated `@Nullable T`. But for a type like `Predicate<T>`, we don't want a `Predicate<@Nullable String>` to throw an exception if passed `null`. The only case in which a class should _definitely_ throw for such a parameter is if it doesn't permit nullable type arguments at all (like `ImmutableList`). Yet, in our new world, we don't want to annotate the argument of `Predicate.apply` as `@Nullable`. The annotation `@ParametricNullness` is our new way of distinguishing `Predicate` (where we'll use it) from `ImmutableList` (where we won't). Eventually, we will remove the annotation, at which point we'll either update `NullPointerTester` to distinguish `Predicate` from `ImmutableList` based on their type parameters' bounds or else we'll disable `NullPointerTester` at least temporarily. RELNOTES=n/a PiperOrigin-RevId: 366867268
Diffstat (limited to 'android/guava-testlib/src/com/google/common')
-rw-r--r--android/guava-testlib/src/com/google/common/testing/NullPointerTester.java3
1 files changed, 2 insertions, 1 deletions
diff --git a/android/guava-testlib/src/com/google/common/testing/NullPointerTester.java b/android/guava-testlib/src/com/google/common/testing/NullPointerTester.java
index a32a53b7b..1099854d1 100644
--- a/android/guava-testlib/src/com/google/common/testing/NullPointerTester.java
+++ b/android/guava-testlib/src/com/google/common/testing/NullPointerTester.java
@@ -474,7 +474,8 @@ public final class NullPointerTester {
}
private static final ImmutableSet<String> NULLABLE_ANNOTATION_SIMPLE_NAMES =
- ImmutableSet.of("CheckForNull", "Nullable", "NullableDecl", "NullableType");
+ ImmutableSet.of(
+ "CheckForNull", "Nullable", "NullableDecl", "NullableType", "ParametricNullness");
static boolean isNullable(AnnotatedElement e) {
for (Annotation annotation : e.getAnnotations()) {