import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; import java.lang.annotation.ElementType; import java.util.Comparator; import java.util.function.Supplier; @NullMarked class Main { public static void main(String[] args) { Main.<@Nullable Object>fNonNullBound(() -> getNullableObject()); Main.<@Nullable Object>fNonNullBound(Main::getNullableObject); } Comparator getComparator() { return Comparator.<@Nullable String>naturalOrder(); } static T fNullableBound(Supplier supplier){ return supplier.get(); } static T fNonNullBound(Supplier supplier){ return supplier.get(); } static @Nullable Object getNullableObject() { return null; } @NullableScope static class NullableScopeClass { void test() { Main.<Object>fNonNullBound(Main::getNullableObject); } } } @javax.annotation.meta.TypeQualifierDefault(ElementType.TYPE_USE) @javax.annotation.Nullable @java.lang.annotation.Target(ElementType.TYPE_USE) @interface NullableScope {}