Skip to content

Commit 9738e48

Browse files
philwebbjhoeller
authored andcommitted
Use ReflectionUtils to get declared methods
Update `StandardAnnotationMetadata` to use `ReflectionUtils` when obtaining declared methods. This update is primarily so that the common method cache can be used. Closes gh-22907
1 parent 1fa5937 commit 9738e48

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

spring-core/src/main/java/org/springframework/core/type/StandardAnnotationMetadata.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.springframework.core.annotation.AnnotationUtils;
2828
import org.springframework.lang.Nullable;
2929
import org.springframework.util.MultiValueMap;
30+
import org.springframework.util.ReflectionUtils;
3031

3132
/**
3233
* {@link AnnotationMetadata} implementation that uses standard reflection
@@ -151,7 +152,7 @@ public MultiValueMap<String, Object> getAllAnnotationAttributes(String annotatio
151152
public boolean hasAnnotatedMethods(String annotationName) {
152153
if (AnnotationUtils.isCandidateClass(getIntrospectedClass(), annotationName)) {
153154
try {
154-
Method[] methods = getIntrospectedClass().getDeclaredMethods();
155+
Method[] methods = ReflectionUtils.getDeclaredMethods(getIntrospectedClass());
155156
for (Method method : methods) {
156157
if (!method.isBridge() && method.getAnnotations().length > 0 &&
157158
AnnotatedElementUtils.isAnnotated(method, annotationName)) {

0 commit comments

Comments
 (0)