diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java index 419d6ddbe7..ec57c0230a 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java @@ -121,6 +121,9 @@ public abstract class AnnotationUtils { private static final Map, Map> attributeAliasesCache = new ConcurrentReferenceHashMap, Map>(256); + private static final Map, List> attributeMethodsCache = + new ConcurrentReferenceHashMap, List>(256); + private static transient Log logger; @@ -1311,13 +1314,22 @@ public abstract class AnnotationUtils { * @since 4.2 */ static List getAttributeMethods(Class annotationType) { - List methods = new ArrayList(); + + List methods = attributeMethodsCache.get(annotationType); + if (methods != null) { + return methods; + } + + methods = new ArrayList(); for (Method method : annotationType.getDeclaredMethods()) { if ((method.getParameterTypes().length == 0) && (method.getReturnType() != void.class)) { ReflectionUtils.makeAccessible(method); methods.add(method); } } + + attributeMethodsCache.put(annotationType, methods); + return methods; }