Browse Source

Remove redundant declarations of JSpecify's @⁠NonNull annotation

Closes gh-35341
pull/35363/head
Sam Brannen 4 months ago
parent
commit
887ef75700
  1. 4
      spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfoFactory.java
  2. 3
      spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotations.java
  3. 13
      spring-core/src/test/java/org/springframework/core/annotation/AnnotationsScannerTests.java

4
spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfoFactory.java

@ -20,8 +20,6 @@ import java.beans.BeanInfo;
import java.beans.IntrospectionException; import java.beans.IntrospectionException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import org.jspecify.annotations.NonNull;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
/** /**
@ -44,7 +42,7 @@ import org.springframework.core.Ordered;
public class ExtendedBeanInfoFactory extends StandardBeanInfoFactory { public class ExtendedBeanInfoFactory extends StandardBeanInfoFactory {
@Override @Override
public @NonNull BeanInfo getBeanInfo(Class<?> beanClass) throws IntrospectionException { public BeanInfo getBeanInfo(Class<?> beanClass) throws IntrospectionException {
BeanInfo beanInfo = super.getBeanInfo(beanClass); BeanInfo beanInfo = super.getBeanInfo(beanClass);
return (supports(beanClass) ? new ExtendedBeanInfo(beanInfo) : beanInfo); return (supports(beanClass) ? new ExtendedBeanInfo(beanInfo) : beanInfo);
} }

3
spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotations.java

@ -29,7 +29,6 @@ import java.util.function.Predicate;
import java.util.stream.Stream; import java.util.stream.Stream;
import java.util.stream.StreamSupport; import java.util.stream.StreamSupport;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable; import org.jspecify.annotations.Nullable;
/** /**
@ -483,7 +482,7 @@ final class TypeMappedAnnotations implements MergedAnnotations {
} }
@Override @Override
public @NonNull List<Aggregate> finish(@Nullable List<Aggregate> processResult) { public List<Aggregate> finish(@Nullable List<Aggregate> processResult) {
return this.aggregates; return this.aggregates;
} }
} }

13
spring-core/src/test/java/org/springframework/core/annotation/AnnotationsScannerTests.java

@ -29,7 +29,6 @@ import java.util.Objects;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable; import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -470,13 +469,13 @@ class AnnotationsScannerTests {
new AnnotationsProcessor<Object, String>() { new AnnotationsProcessor<Object, String>() {
@Override @Override
public @NonNull String doWithAggregate(Object context, int aggregateIndex) { public String doWithAggregate(Object context, int aggregateIndex) {
return ""; return "";
} }
@Override @Override
public @NonNull String doWithAnnotations(Object context, int aggregateIndex, public String doWithAnnotations(Object context, int aggregateIndex,
@Nullable Object source, @Nullable Annotation @Nullable [] annotations) { @Nullable Object source, @Nullable Annotation[] annotations) {
throw new IllegalStateException("Should not call"); throw new IllegalStateException("Should not call");
} }
@ -502,13 +501,13 @@ class AnnotationsScannerTests {
new AnnotationsProcessor<Object, String>() { new AnnotationsProcessor<Object, String>() {
@Override @Override
public @NonNull String doWithAnnotations(Object context, int aggregateIndex, public String doWithAnnotations(Object context, int aggregateIndex,
@Nullable Object source, @Nullable Annotation @Nullable [] annotations) { @Nullable Object source, @Nullable Annotation[] annotations) {
return "K"; return "K";
} }
@Override @Override
public @NonNull String finish(@Nullable String result) { public String finish(@Nullable String result) {
return "O" + result; return "O" + result;
} }

Loading…
Cancel
Save