From f0768e54414baf98436924d02cd7c6f61be0dc26 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Sat, 9 Mar 2019 23:54:41 -0800 Subject: [PATCH] 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 --- .../core/annotation/AnnotationsScanner.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationsScanner.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationsScanner.java index edc240a80307..608d9890d0e8 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationsScanner.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationsScanner.java @@ -145,8 +145,8 @@ private static R processClassInheritedAnnotations(C context, Class sou 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 @@ else if (annotatedElement instanceof Member) { 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) {