Skip to content

Commit dba7bf7

Browse files
committed
Avoid unnecessary setAccessible call in AttributeMethods
Closes spring-projectsgh-23829
1 parent 422c268 commit dba7bf7

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

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

+4-7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.springframework.lang.Nullable;
2626
import org.springframework.util.Assert;
2727
import org.springframework.util.ConcurrentReferenceHashMap;
28+
import org.springframework.util.ReflectionUtils;
2829

2930
/**
3031
* Provides a quick way to access the attribute methods of an {@link Annotation}
@@ -73,15 +74,11 @@ private AttributeMethods(@Nullable Class<? extends Annotation> annotationType, M
7374
if (method.getDefaultValue() != null) {
7475
foundDefaultValueMethod = true;
7576
}
76-
if (type.isAnnotation() ||
77-
(type.isArray() && type.getComponentType().isAnnotation())) {
77+
if (type.isAnnotation() || (type.isArray() && type.getComponentType().isAnnotation())) {
7878
foundNestedAnnotation = true;
7979
}
80-
method.setAccessible(true);
81-
this.canThrowTypeNotPresentException[i] =
82-
type == Class.class ||
83-
type == Class[].class ||
84-
type.isEnum();
80+
ReflectionUtils.makeAccessible(method);
81+
this.canThrowTypeNotPresentException[i] = (type == Class.class || type == Class[].class || type.isEnum());
8582
}
8683
this.hasDefaultValueMethod = foundDefaultValueMethod;
8784
this.hasNestedAnnotation = foundNestedAnnotation;

0 commit comments

Comments
 (0)