From dba7bf7ec1d3629a4f9ae0458b9c62176c94b139 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 30 Oct 2019 14:30:26 +0100 Subject: [PATCH] Avoid unnecessary setAccessible call in AttributeMethods Closes gh-23829 --- .../core/annotation/AttributeMethods.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AttributeMethods.java b/spring-core/src/main/java/org/springframework/core/annotation/AttributeMethods.java index 13f0d64e03..f5c06ff051 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AttributeMethods.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AttributeMethods.java @@ -25,6 +25,7 @@ import java.util.Map; import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.ConcurrentReferenceHashMap; +import org.springframework.util.ReflectionUtils; /** * Provides a quick way to access the attribute methods of an {@link Annotation} @@ -73,15 +74,11 @@ final class AttributeMethods { if (method.getDefaultValue() != null) { foundDefaultValueMethod = true; } - if (type.isAnnotation() || - (type.isArray() && type.getComponentType().isAnnotation())) { + if (type.isAnnotation() || (type.isArray() && type.getComponentType().isAnnotation())) { foundNestedAnnotation = true; } - method.setAccessible(true); - this.canThrowTypeNotPresentException[i] = - type == Class.class || - type == Class[].class || - type.isEnum(); + ReflectionUtils.makeAccessible(method); + this.canThrowTypeNotPresentException[i] = (type == Class.class || type == Class[].class || type.isEnum()); } this.hasDefaultValueMethod = foundDefaultValueMethod; this.hasNestedAnnotation = foundNestedAnnotation; -- GitLab