Skip to content

Commit

Permalink
Register hints for superinterface methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
OlgaMaciaszek committed May 13, 2024
1 parent c276f1c commit a01c7c7
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 a01c7c7

Please sign in to comment.