From 2d7e5d0c585341832e86831caf8188c9ba26ecc5 Mon Sep 17 00:00:00 2001 From: Suzanne Millstein Date: Fri, 14 Apr 2023 09:33:22 -0700 Subject: [PATCH] Annotated javax.lang.model.util.Types for nullness. --- .../share/classes/javax/lang/model/util/Types.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/java.compiler/share/classes/javax/lang/model/util/Types.java b/src/java.compiler/share/classes/javax/lang/model/util/Types.java index 1206c9e0d76bb..7e65d7584d74f 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/Types.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/Types.java @@ -25,7 +25,9 @@ package javax.lang.model.util; +import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.framework.qual.AnnotatedFor; import java.lang.annotation.Annotation; import java.lang.annotation.AnnotationTypeMismatchException; import java.lang.annotation.IncompleteAnnotationException; @@ -45,6 +47,7 @@ * @see javax.annotation.processing.ProcessingEnvironment#getTypeUtils * @since 1.6 */ +@AnnotatedFor("nullness") public interface Types { /** @@ -56,7 +59,7 @@ public interface Types { * @param t the type to map to an element * @return the element corresponding to the given type */ - Element asElement(TypeMirror t); + @Nullable Element asElement(TypeMirror t); /** * Tests whether two {@code TypeMirror} objects represent the same type. @@ -235,8 +238,8 @@ public interface Types { * @param superBound the super (lower) bound, or {@code null} if none * @throws IllegalArgumentException if bounds are not valid */ - WildcardType getWildcardType(TypeMirror extendsBound, - TypeMirror superBound); + WildcardType getWildcardType(@Nullable TypeMirror extendsBound, + @Nullable TypeMirror superBound); /** * {@return the type corresponding to a type element and @@ -292,7 +295,7 @@ WildcardType getWildcardType(TypeMirror extendsBound, * type arguments are given, or if an inappropriate type * argument, type element, or containing type is provided */ - DeclaredType getDeclaredType(DeclaredType containing, + DeclaredType getDeclaredType(@Nullable DeclaredType containing, TypeElement typeElem, TypeMirror... typeArgs); /**