|
39 | 39 | import org.springframework.aop.framework.autoproxy.AutoProxyUtils;
|
40 | 40 | import org.springframework.aot.generate.GeneratedMethod;
|
41 | 41 | import org.springframework.aot.generate.GenerationContext;
|
| 42 | +import org.springframework.aot.hint.ExecutableMode; |
42 | 43 | import org.springframework.aot.hint.ResourceHints;
|
| 44 | +import org.springframework.aot.hint.RuntimeHints; |
43 | 45 | import org.springframework.aot.hint.TypeReference;
|
44 | 46 | import org.springframework.beans.PropertyValues;
|
45 | 47 | import org.springframework.beans.factory.BeanClassLoaderAware;
|
@@ -739,20 +741,22 @@ public CodeBlock generateSetBeanDefinitionPropertiesCode(GenerationContext gener
|
739 | 741 | public CodeBlock generateInstanceSupplierCode(GenerationContext generationContext,
|
740 | 742 | BeanRegistrationCode beanRegistrationCode, Executable constructorOrFactoryMethod,
|
741 | 743 | boolean allowDirectSupplierShortcut) {
|
| 744 | + Executable executableToUse = proxyExecutable(generationContext.getRuntimeHints(), constructorOrFactoryMethod); |
742 | 745 | return super.generateInstanceSupplierCode(generationContext, beanRegistrationCode,
|
743 |
| - proxyExecutable(constructorOrFactoryMethod), allowDirectSupplierShortcut); |
| 746 | + executableToUse, allowDirectSupplierShortcut); |
744 | 747 | }
|
745 | 748 |
|
746 |
| - private Executable proxyExecutable(Executable rawClassExecutable) { |
747 |
| - if (rawClassExecutable instanceof Constructor<?>) { |
| 749 | + private Executable proxyExecutable(RuntimeHints runtimeHints, Executable userExecutable) { |
| 750 | + if (userExecutable instanceof Constructor<?> userConstructor) { |
748 | 751 | try {
|
749 |
| - return this.proxyClass.getConstructor(rawClassExecutable.getParameterTypes()); |
| 752 | + runtimeHints.reflection().registerConstructor(userConstructor, ExecutableMode.INTROSPECT); |
| 753 | + return this.proxyClass.getConstructor(userExecutable.getParameterTypes()); |
750 | 754 | }
|
751 | 755 | catch (NoSuchMethodException ex) {
|
752 | 756 | throw new IllegalStateException("No matching constructor found on proxy " + this.proxyClass, ex);
|
753 | 757 | }
|
754 | 758 | }
|
755 |
| - return rawClassExecutable; |
| 759 | + return userExecutable; |
756 | 760 | }
|
757 | 761 |
|
758 | 762 | }
|
|
0 commit comments