From dc252a2048bd7047aa8ed500eb7c9f8205dd1cf0 Mon Sep 17 00:00:00 2001 From: Chris Povirk Date: Mon, 7 Oct 2024 11:52:50 -0400 Subject: [PATCH] Opportunistically add a new `@Nullable` annotations to `ObjectInputFilter`. (#91) I looked at this class by accident when I was reviewing changes to classes that are `@NullMarked`. (`ObjectInputFilter` is not.) Still, since I saw a few places to add `@Nullable`, I'm doing that now, even as I decline to fully null-mark the class. --- .../share/classes/java/io/ObjectInputFilter.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/java.base/share/classes/java/io/ObjectInputFilter.java b/src/java.base/share/classes/java/io/ObjectInputFilter.java index 879820761c1..8ce95a9a3c2 100644 --- a/src/java.base/share/classes/java/io/ObjectInputFilter.java +++ b/src/java.base/share/classes/java/io/ObjectInputFilter.java @@ -25,6 +25,8 @@ package java.io; +import org.jspecify.annotations.Nullable; + import jdk.internal.access.SharedSecrets; import jdk.internal.util.StaticProperty; @@ -379,7 +381,7 @@ static ObjectInputFilter rejectFilter(Predicate> predicate, Status othe * @return an {@link ObjectInputFilter} that merges the status of the filter and another filter * @since 17 */ - static ObjectInputFilter merge(ObjectInputFilter filter, ObjectInputFilter anotherFilter) { + static ObjectInputFilter merge(ObjectInputFilter filter, @Nullable ObjectInputFilter anotherFilter) { Objects.requireNonNull(filter, "filter"); return (anotherFilter == null) ? filter : new Config.MergeFilter(filter, anotherFilter); } @@ -445,7 +447,7 @@ interface FilterInfo { * * @return class of an object being deserialized; may be null */ - Class serialClass(); + @Nullable Class serialClass(); /** * The number of array elements when deserializing an array of the class. @@ -717,7 +719,7 @@ private static void traceFilter(String msg, Object... args) { * system property {@code jdk.serialFilter} or * the security property {@code jdk.serialFilter} fails. */ - public static ObjectInputFilter getSerialFilter() { + public static @Nullable ObjectInputFilter getSerialFilter() { if (invalidFilterMessage != null) { throw new IllegalStateException(invalidFilterMessage); }