Skip to content

Commit

Permalink
Register hints for superinterface methods. (spring-cloud#1030)
Browse files Browse the repository at this point in the history
  • Loading branch information
OlgaMaciaszek authored and app committed May 20, 2024
1 parent a971264 commit 3983501
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.springframework.aot.generate.GenerationContext;
import org.springframework.aot.generate.MethodReference;
import org.springframework.aot.hint.BindingReflectionHintsRegistrar;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.ReflectionHints;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.beans.MutablePropertyValues;
Expand Down Expand Up @@ -107,6 +108,21 @@ private void registerMethodHints(ReflectionHints hints, Class<?> clazz) {
for (Method method : clazz.getMethods()) {
registerMethodHints(hints, method);
}
introspectPublicMethodsOnAllInterfaces(hints, clazz);
}

// from Spring Framework BeanRegistrationsAotContribution
private void introspectPublicMethodsOnAllInterfaces(ReflectionHints hints, Class<?> clazz) {
Class<?> currentClass = clazz;
while (currentClass != null && currentClass != Object.class) {
for (Class<?> interfaceType : currentClass.getInterfaces()) {
if (!ClassUtils.isJavaLanguageInterface(interfaceType)) {
hints.registerType(interfaceType, MemberCategory.INTROSPECT_PUBLIC_METHODS);
introspectPublicMethodsOnAllInterfaces(hints, interfaceType);
}
}
currentClass = currentClass.getSuperclass();
}
}

private void registerMethodHints(ReflectionHints hints, Method method) {
Expand Down

0 comments on commit 3983501

Please sign in to comment.