Update AOT support after RuntimeHints changes
This commit adapts AOT support in various modules after the RuntimeHints and related deprecation changes. `MemberCategory.INTROSPECT_*` hints are now removed and `MemberCategory.*_FIELDS` are replaced with `MemberCategory.INVOKE*_FIELDS` when invocation is needed. Usage of `RuntimeHintsAgent` are also deprecated. Closes gh-33847
This commit is contained in:
@@ -960,7 +960,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||
return CodeBlock.of("$L.resolveAndSet($L, $L)", resolver,
|
||||
REGISTERED_BEAN_PARAMETER, INSTANCE_PARAMETER);
|
||||
}
|
||||
hints.reflection().registerMethod(method, ExecutableMode.INTROSPECT);
|
||||
hints.reflection().registerType(method.getDeclaringClass());
|
||||
return CodeBlock.of("$L.$L($L.resolve($L))", INSTANCE_PARAMETER,
|
||||
method.getName(), resolver, REGISTERED_BEAN_PARAMETER);
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.aop.framework.autoproxy.AutoProxyUtils;
|
||||
import org.springframework.aot.generate.GeneratedMethod;
|
||||
import org.springframework.aot.generate.GenerationContext;
|
||||
import org.springframework.aot.hint.ExecutableMode;
|
||||
import org.springframework.aot.hint.MemberCategory;
|
||||
import org.springframework.aot.hint.ResourceHints;
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
@@ -812,7 +811,7 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
|
||||
Executable userExecutable = instantiationDescriptor.executable();
|
||||
if (userExecutable instanceof Constructor<?> userConstructor) {
|
||||
try {
|
||||
runtimeHints.reflection().registerConstructor(userConstructor, ExecutableMode.INTROSPECT);
|
||||
runtimeHints.reflection().registerType(userConstructor.getDeclaringClass());
|
||||
Constructor<?> constructor = this.proxyClass.getConstructor(userExecutable.getParameterTypes());
|
||||
return new InstantiationDescriptor(constructor);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.context.aot;
|
||||
|
||||
import org.springframework.aot.generate.GenerationContext;
|
||||
import org.springframework.aot.hint.MemberCategory;
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.beans.factory.aot.BeanRegistrationAotContribution;
|
||||
import org.springframework.beans.factory.aot.BeanRegistrationAotProcessor;
|
||||
@@ -61,7 +60,7 @@ class KotlinReflectionBeanRegistrationAotProcessor implements BeanRegistrationAo
|
||||
|
||||
private void registerHints(Class<?> type, RuntimeHints runtimeHints) {
|
||||
if (KotlinDetector.isKotlinType(type)) {
|
||||
runtimeHints.reflection().registerType(type, MemberCategory.INTROSPECT_DECLARED_METHODS);
|
||||
runtimeHints.reflection().registerType(type);
|
||||
}
|
||||
Class<?> superClass = type.getSuperclass();
|
||||
if (superClass != null) {
|
||||
|
||||
@@ -237,7 +237,7 @@ class BeanValidationBeanRegistrationAotProcessor implements BeanRegistrationAotP
|
||||
public void applyTo(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode) {
|
||||
ReflectionHints hints = generationContext.getRuntimeHints().reflection();
|
||||
for (Class<?> validatedClass : this.validatedClasses) {
|
||||
hints.registerType(validatedClass, MemberCategory.DECLARED_FIELDS);
|
||||
hints.registerType(validatedClass, MemberCategory.INVOKE_DECLARED_FIELDS);
|
||||
}
|
||||
for (Class<? extends ConstraintValidator<?, ?>> constraintValidatorClass : this.constraintValidatorClasses) {
|
||||
hints.registerType(constraintValidatorClass, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
|
||||
|
||||
Reference in New Issue
Block a user