From 3e19ce2d929387adfe7c6498256d2fa53f378c28 Mon Sep 17 00:00:00 2001 From: Chris Povirk Date: Mon, 7 Oct 2024 10:48:54 -0400 Subject: [PATCH] Annotate `javax.lang.model.util.Types`. (#94) adapted from https://github.com/typetools/jdk/commit/7f2fadb5a25115bef34ad5599aa9a4de273f224a Co-authored-by: Suzanne Millstein --- .../share/classes/javax/lang/model/util/Types.java | 12 ++++++++---- 1 file changed, 8 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 266d63178ba..ca400645aab 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,6 +25,9 @@ package javax.lang.model.util; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + import java.util.List; import javax.lang.model.element.*; import javax.lang.model.type.*; @@ -53,6 +56,7 @@ * @see javax.annotation.processing.ProcessingEnvironment#getTypeUtils * @since 1.6 */ +@NullMarked public interface Types { /** @@ -79,7 +83,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. @@ -271,8 +275,8 @@ public interface Types { * @throws IllegalArgumentException if bounds are not valid * @jls 4.5.1 Type Arguments of Parameterized Types */ - WildcardType getWildcardType(TypeMirror extendsBound, - TypeMirror superBound); + WildcardType getWildcardType(@Nullable TypeMirror extendsBound, + @Nullable TypeMirror superBound); /** * {@return the type corresponding to a type element and @@ -332,7 +336,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); /**