Browse Source

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
pull/25019/head
Phillip Webb 6 years ago committed by Juergen Hoeller
parent
commit
9738e4886c
  1. 3
      spring-core/src/main/java/org/springframework/core/type/StandardAnnotationMetadata.java

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

@ -27,6 +27,7 @@ import org.springframework.core.annotation.AnnotatedElementUtils; @@ -27,6 +27,7 @@ import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.lang.Nullable;
import org.springframework.util.MultiValueMap;
import org.springframework.util.ReflectionUtils;
/**
* {@link AnnotationMetadata} implementation that uses standard reflection
@ -151,7 +152,7 @@ public class StandardAnnotationMetadata extends StandardClassMetadata implements @@ -151,7 +152,7 @@ public class StandardAnnotationMetadata extends StandardClassMetadata implements
public boolean hasAnnotatedMethods(String annotationName) {
if (AnnotationUtils.isCandidateClass(getIntrospectedClass(), annotationName)) {
try {
Method[] methods = getIntrospectedClass().getDeclaredMethods();
Method[] methods = ReflectionUtils.getDeclaredMethods(getIntrospectedClass());
for (Method method : methods) {
if (!method.isBridge() && method.getAnnotations().length > 0 &&
AnnotatedElementUtils.isAnnotated(method, annotationName)) {

Loading…
Cancel
Save