From 3a890033b78dcc9d4db8273b4d894894b9ca86a0 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 3 Aug 2022 14:51:52 +0200 Subject: [PATCH] Fix custom bean definition to stop using reflection See gh-28915 --- .../context/annotation/ConfigurationClassPostProcessor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java index de9c519135..690ea75053 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java @@ -568,8 +568,8 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo MAPPINGS_VARIABLE, type, from)); builder.addStatement("$T $L = new $T($T.class)", RootBeanDefinition.class, BEAN_DEFINITION_VARIABLE, RootBeanDefinition.class, ImportAwareAotBeanPostProcessor.class); - builder.addStatement("$L.getConstructorArgumentValues().addIndexedArgumentValue(0, $L)", - BEAN_DEFINITION_VARIABLE, MAPPINGS_VARIABLE); + builder.addStatement("$L.setInstanceSupplier(() -> new $T($L))", + BEAN_DEFINITION_VARIABLE, ImportAwareAotBeanPostProcessor.class, MAPPINGS_VARIABLE); builder.addStatement("$L.registerBeanDefinition($S, $L)", BEAN_FACTORY_VARIABLE, BEAN_NAME, BEAN_DEFINITION_VARIABLE); return builder.build();