Spring Data has a use-case in which it requires a stable method order (ordering of methods within a class file). To detect method ordering, it extended Spring Framework's ClassMetadata
and ASM visitors to expose Set<MethodMetadata> getMethods()
.
After removal of AnnotationMetadataReadingVisitor
, there's no extension point available and Spring Data would have to hold a copy of all involved components to determine the method order.
It would be good to have access to MethodMetadata
from ClassMetadata
, ideally as MethodMetadata[] getMethods()
or Collection<MethodMetadata>
.
See for further reference:
https://github.com/spring-projects/spring-data-commons/blob/788457c90132ae7ca893791d091279faa8e76abe/src/main/java/org/springframework/data/type/MethodsMetadata.java
https://github.com/spring-projects/spring-data-commons/blob/788457c90132ae7ca893791d091279faa8e76abe/src/main/java/org/springframework/data/type/classreading/DefaultMethodsMetadataReader.java#L121-L162
Comment From: jhoeller
I ended up introducing getDeclaredMethods()
on AnnotationMetadata
since that is where getAnnotatedMethods
lives already, and also since MethodMetadata
includes annotation functionality as well. (The distinction between ClassMetadata
and AnnotationMetadata
is outdated in any case, with the present implementation we'll always retrieve full annotation metadata in any case.)