Skip to content

Commit 7244c9a

Browse files
philwebbjhoeller
authored andcommitted
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
1 parent db8eaec commit 7244c9a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ private static <C, R> R processClassInheritedAnnotations(C context, Class<?> sou
145145
int remaining = Integer.MAX_VALUE;
146146
int aggregateIndex = 0;
147147
Class<?> root = source;
148-
while (source != null && source != Object.class
149-
&& !hasPlainJavaAnnotationsOnly(source) && remaining > 0) {
148+
while (source != null && source != Object.class && remaining > 0
149+
&& !hasPlainJavaAnnotationsOnly(source)) {
150150
R result = processor.doWithAggregate(context, aggregateIndex);
151151
if (result != null) {
152152
return result;
@@ -524,7 +524,9 @@ else if (annotatedElement instanceof Member) {
524524
String name = type.getName();
525525
return type.equals(Ordered.class) ||
526526
name.startsWith("java") ||
527-
name.startsWith("org.springframework.lang.");
527+
name.startsWith("org.springframework.lang.") ||
528+
name.startsWith("org.springframework.util.") ||
529+
(name.startsWith("com.sun") && !name.contains("Proxy"));
528530
}
529531

530532
private static boolean isWithoutHierarchy(AnnotatedElement source) {

0 commit comments

Comments
 (0)