Browse Source

Add more aggressive annotation element filtering

Refine the element filtering performed by `AnnotationsScanner` to also
cover `org.springframework.util` and most `com.sun` classes which turn
out to be referenced quite frequently and which we know contain no
useful annotations.

See gh-21697
pull/22645/head
Phillip Webb 6 years ago committed by Juergen Hoeller
parent
commit
7244c9aea1
  1. 8
      spring-core/src/main/java/org/springframework/core/annotation/AnnotationsScanner.java

8
spring-core/src/main/java/org/springframework/core/annotation/AnnotationsScanner.java

@ -145,8 +145,8 @@ abstract class AnnotationsScanner { @@ -145,8 +145,8 @@ abstract class AnnotationsScanner {
int remaining = Integer.MAX_VALUE;
int aggregateIndex = 0;
Class<?> root = source;
while (source != null && source != Object.class
&& !hasPlainJavaAnnotationsOnly(source) && remaining > 0) {
while (source != null && source != Object.class && remaining > 0
&& !hasPlainJavaAnnotationsOnly(source)) {
R result = processor.doWithAggregate(context, aggregateIndex);
if (result != null) {
return result;
@ -524,7 +524,9 @@ abstract class AnnotationsScanner { @@ -524,7 +524,9 @@ abstract class AnnotationsScanner {
String name = type.getName();
return type.equals(Ordered.class) ||
name.startsWith("java") ||
name.startsWith("org.springframework.lang.");
name.startsWith("org.springframework.lang.") ||
name.startsWith("org.springframework.util.") ||
(name.startsWith("com.sun") && !name.contains("Proxy"));
}
private static boolean isWithoutHierarchy(AnnotatedElement source) {

Loading…
Cancel
Save