From 40b2d26bd4e15f7eefe7f07aeb733761b9e241d5 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 8 Jul 2016 13:21:31 +0200 Subject: [PATCH] Avoid reflection for @Repeatable look-ups Issue: SPR-13188 --- .../core/annotation/AnnotationUtils.java | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) 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 3ef0db89b44..da7d6df6d42 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 @@ -17,6 +17,7 @@ package org.springframework.core.annotation; import java.lang.annotation.Annotation; +import java.lang.annotation.Repeatable; import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Array; import java.lang.reflect.InvocationHandler; @@ -111,8 +112,6 @@ public abstract class AnnotationUtils { */ public static final String VALUE = "value"; - private static final String REPEATABLE_CLASS_NAME = "java.lang.annotation.Repeatable"; - private static final Map findAnnotationCache = new ConcurrentReferenceHashMap<>(256); @@ -1703,19 +1702,9 @@ public abstract class AnnotationUtils { * {@code null}. * @since 4.2 */ - @SuppressWarnings("unchecked") static Class resolveContainerAnnotationType(Class annotationType) { - try { - Annotation repeatable = getAnnotation(annotationType, REPEATABLE_CLASS_NAME); - if (repeatable != null) { - Object value = getValue(repeatable); - return (Class) value; - } - } - catch (Exception ex) { - handleIntrospectionFailure(annotationType, ex); - } - return null; + Repeatable repeatable = getAnnotation(annotationType, Repeatable.class); + return (repeatable != null ? repeatable.value() : null); } /**