diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/AopProxyUtilsTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/AopProxyUtilsTests.java index 783d668645..9199b00571 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/AopProxyUtilsTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/AopProxyUtilsTests.java @@ -148,6 +148,7 @@ class AopProxyUtilsTests { sealed interface SealedInterface { } + @SuppressWarnings("unused") static final class SealedClass implements SealedInterface { } diff --git a/spring-beans/src/jmh/java/org/springframework/beans/BeanUtilsBenchmark.java b/spring-beans/src/jmh/java/org/springframework/beans/BeanUtilsBenchmark.java index bbcf125773..b656648d87 100644 --- a/spring-beans/src/jmh/java/org/springframework/beans/BeanUtilsBenchmark.java +++ b/spring-beans/src/jmh/java/org/springframework/beans/BeanUtilsBenchmark.java @@ -51,8 +51,8 @@ public class BeanUtilsBenchmark { return BeanUtils.instantiateClass(this.constructor, 1, "str"); } - static class TestClass1{ - }; + static class TestClass1 { + } @SuppressWarnings("unused") static class TestClass2 { diff --git a/spring-context/src/main/java/org/springframework/cache/annotation/SpringCacheAnnotationParser.java b/spring-context/src/main/java/org/springframework/cache/annotation/SpringCacheAnnotationParser.java index 535217853b..e65187543d 100644 --- a/spring-context/src/main/java/org/springframework/cache/annotation/SpringCacheAnnotationParser.java +++ b/spring-context/src/main/java/org/springframework/cache/annotation/SpringCacheAnnotationParser.java @@ -22,7 +22,6 @@ import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; -import java.util.LinkedHashSet; import java.util.Set; import org.springframework.cache.interceptor.CacheEvictOperation; @@ -49,14 +48,7 @@ import org.springframework.util.StringUtils; @SuppressWarnings("serial") public class SpringCacheAnnotationParser implements CacheAnnotationParser, Serializable { - private static final Set> CACHE_OPERATION_ANNOTATIONS = new LinkedHashSet<>(8); - - static { - CACHE_OPERATION_ANNOTATIONS.add(Cacheable.class); - CACHE_OPERATION_ANNOTATIONS.add(CacheEvict.class); - CACHE_OPERATION_ANNOTATIONS.add(CachePut.class); - CACHE_OPERATION_ANNOTATIONS.add(Caching.class); - } + private static final Set> CACHE_OPERATION_ANNOTATIONS = Set.of(Cacheable.class, CacheEvict.class, CachePut.class, Caching.class); @Override diff --git a/spring-core/src/main/java/org/springframework/aot/hint/annotation/ReflectiveRuntimeHintsRegistrar.java b/spring-core/src/main/java/org/springframework/aot/hint/annotation/ReflectiveRuntimeHintsRegistrar.java index 0459977e3b..eb7ed7ed68 100644 --- a/spring-core/src/main/java/org/springframework/aot/hint/annotation/ReflectiveRuntimeHintsRegistrar.java +++ b/spring-core/src/main/java/org/springframework/aot/hint/annotation/ReflectiveRuntimeHintsRegistrar.java @@ -25,7 +25,6 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Consumer; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.springframework.aot.hint.ReflectionHints; @@ -39,7 +38,7 @@ import org.springframework.util.ReflectionUtils; * * @author Stephane Nicoll * @author Andy Wilkinson - * since 6.0 + * @since 6.0 */ public class ReflectiveRuntimeHintsRegistrar { @@ -92,13 +91,13 @@ public class ReflectiveRuntimeHintsRegistrar { @SuppressWarnings("unchecked") private Entry createEntry(AnnotatedElement element) { - List> processorClasses = + List processors = MergedAnnotations.from(element, MergedAnnotations.SearchStrategy.TYPE_HIERARCHY) .stream(Reflective.class).flatMap(annotation -> Stream.of(annotation.getClassArray("value"))) - .map(type -> (Class) type).collect(Collectors.toList()); - List processors = processorClasses.stream().distinct() - .map(processorClass -> this.processors.computeIfAbsent(processorClass, this::instantiateClass)) - .toList(); + .map(type -> (Class) type) + .distinct() + .map(processorClass -> this.processors.computeIfAbsent(processorClass, this::instantiateClass)) + .toList(); ReflectiveProcessor processorToUse = (processors.size() == 1 ? processors.get(0) : new DelegateReflectiveProcessor(processors)); return new Entry(element, processorToUse); diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Encoder.java b/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Encoder.java index 21c55e4fc7..5f5f815a37 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Encoder.java +++ b/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Encoder.java @@ -20,7 +20,6 @@ import java.io.IOException; import java.lang.annotation.Annotation; import java.nio.charset.Charset; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; @@ -195,7 +194,7 @@ public abstract class AbstractJackson2Encoder extends Jackson2CodecSupport imple delimiter, EMPTY_BYTES); return (prefix.length > 0 ? - bufferFactory.join(Arrays.asList(bufferFactory.wrap(prefix), dataBuffer)) : + bufferFactory.join(List.of(bufferFactory.wrap(prefix), dataBuffer)) : dataBuffer); }) .switchIfEmpty(Mono.fromCallable(() -> bufferFactory.wrap(helper.getPrefix())))