import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReferenceArray; import java.util.stream.Collectors; @NullMarked class Main { public static void main(String[] args) { AtomicReference<@Nullable String> ref = new AtomicReference<>(); AtomicReference ref1 = new AtomicReference<@Nullable String>(); AtomicReference ref2 = new AtomicReference<>(null); AtomicReference ref3 = new AtomicReference<>(""); ThreadLocal<@Nullable String> tl = new ThreadLocal<>(); ThreadLocal tl2 = new ThreadLocal<>() { @Override protected String initialValue() { return null; } }; ThreadLocal tl3 = ThreadLocal.withInitial(() -> null); AtomicReferenceArray<@Nullable String> arr = new AtomicReferenceArray<>(10); AtomicReferenceArray arr2 = new AtomicReferenceArray<>(new String[10]); // technically wrong and should be highlighted, as array contains nulls @Nullable String[] data = new String[10]; AtomicReferenceArray arr3 = new AtomicReferenceArray<>(data); } }