And probably other generated BeanDefinitions by AoT? Example:

    public static BeanDefinition getThemeResolverBeanDefinition() {
      Class<?> beanType = ThemeResolver.class;
      RootBeanDefinition beanDefinition = new RootBeanDefinition(beanType);
      beanDefinition.setInstanceSupplier(getThemeResolverInstanceSupplier());
      return beanDefinition;
    }

Comment From: snicoll

What is the benefit of suppressing the deprecation automatically? I don't think we should be doing that for generated code.

Comment From: akefirad

Well, the code is generated by the library, so there's no way for me to suppress it. That means we'd see the warning during compilation. I guess this would be an issue wherever the source code is used (e.g. code analysis tools maybe? if they look at the generated code as well)

Comment From: snicoll

Yes, I understand that. I don't think your code analysis tool should be looking at generated code. In the absence of an actual problem, I am going to close this. I understand that the warning can be annoying but blindly (automatically) suppressing it is worse IMO.

Comment From: wilkinsona

We discussed this today and we think that there would be some value in the generated code not producing any compilation warnings. The warnings aren't helpful as the user can't do anything to the generated code to fix them.

We could configure Boot to compile the code with -Xlint:none but the warnings will still be present when viewed in an IDE. To avoid them entirely, @SuppressWarnings would have to be generated at build time. This would have to be done in Spring Framework where the code generation is performed. We'll transfer this issue to Framework for their consideration.

Comment From: wilkinsona

This is quite noticeable in Spring Boot 3.2 as almost every app with see at least these deprecation warnings when compiling the AOT-generated code:

> Task :data:hateoas:compileAotJava
/Users/awilkinson/dev/spring-projects/spring-aot-smoke-tests/data/hateoas/build/generated/aotSources/org/springframework/boot/autoconfigure/task/TaskExecutorConfigurations__BeanDefinitions.java:32: warning: [removal] TaskExecutorBuilder in org.springframework.boot.task has been deprecated and marked for removal
    private static BeanInstanceSupplier<TaskExecutorBuilder> getTaskExecutorBuilderInstanceSupplier(
                                        ^
/Users/awilkinson/dev/spring-projects/spring-aot-smoke-tests/data/hateoas/build/generated/aotSources/org/springframework/boot/autoconfigure/task/TaskExecutorConfigurations__BeanDefinitions.java:34: warning: [removal] TaskExecutorBuilder in org.springframework.boot.task has been deprecated and marked for removal
      return BeanInstanceSupplier.<TaskExecutorBuilder>forFactoryMethod(TaskExecutorConfigurations.TaskExecutorBuilderConfiguration.class, "taskExecutorBuilder", TaskExecutionProperties.class, ObjectProvider.class, ObjectProvider.class)
                                   ^
/Users/awilkinson/dev/spring-projects/spring-aot-smoke-tests/data/hateoas/build/generated/aotSources/org/springframework/boot/autoconfigure/task/TaskExecutorConfigurations__BeanDefinitions.java:35: warning: [removal] taskExecutorBuilder(TaskExecutionProperties,ObjectProvider<TaskExecutorCustomizer>,ObjectProvider<TaskDecorator>) in TaskExecutorBuilderConfiguration has been deprecated and marked for removal
              .withGenerator((registeredBean, args) -> registeredBean.getBeanFactory().getBean(TaskExecutorConfigurations.TaskExecutorBuilderConfiguration.class).taskExecutorBuilder(args.get(0), args.get(1), args.get(2)));
                                                                                                                                                                 ^
/Users/awilkinson/dev/spring-projects/spring-aot-smoke-tests/data/hateoas/build/generated/aotSources/org/springframework/boot/autoconfigure/task/TaskExecutorConfigurations__BeanDefinitions.java:43: warning: [removal] TaskExecutorBuilder in org.springframework.boot.task has been deprecated and marked for removal
      beanDefinition.setTargetType(TaskExecutorBuilder.class);
                                   ^
/Users/awilkinson/dev/spring-projects/spring-aot-smoke-tests/data/hateoas/build/generated/aotSources/org/springframework/boot/autoconfigure/task/TaskExecutorConfigurations__BeanDefinitions.java:67: warning: [removal] TaskExecutorBuilder in org.springframework.boot.task has been deprecated and marked for removal
      return BeanInstanceSupplier.<ThreadPoolTaskExecutor>forFactoryMethod(TaskExecutorConfigurations.TaskExecutorConfiguration.class, "applicationTaskExecutor", TaskExecutorBuilder.class, ObjectProvider.class)
                                                                                                                                                                  ^
/Users/awilkinson/dev/spring-projects/spring-aot-smoke-tests/data/hateoas/build/generated/aotSources/org/springframework/boot/autoconfigure/task/TaskSchedulingConfigurations__BeanDefinitions.java:64: warning: [removal] TaskSchedulerBuilder in org.springframework.boot.task has been deprecated and marked for removal
    private static BeanInstanceSupplier<TaskSchedulerBuilder> getTaskSchedulerBuilderInstanceSupplier(
                                        ^
/Users/awilkinson/dev/spring-projects/spring-aot-smoke-tests/data/hateoas/build/generated/aotSources/org/springframework/boot/autoconfigure/task/TaskSchedulingConfigurations__BeanDefinitions.java:66: warning: [removal] TaskSchedulerBuilder in org.springframework.boot.task has been deprecated and marked for removal
      return BeanInstanceSupplier.<TaskSchedulerBuilder>forFactoryMethod(TaskSchedulingConfigurations.TaskSchedulerBuilderConfiguration.class, "taskSchedulerBuilder", TaskSchedulingProperties.class, ObjectProvider.class)
                                   ^
/Users/awilkinson/dev/spring-projects/spring-aot-smoke-tests/data/hateoas/build/generated/aotSources/org/springframework/boot/autoconfigure/task/TaskSchedulingConfigurations__BeanDefinitions.java:75: warning: [removal] TaskSchedulerBuilder in org.springframework.boot.task has been deprecated and marked for removal
      beanDefinition.setTargetType(TaskSchedulerBuilder.class);
                                   ^
Note: /Users/awilkinson/dev/spring-projects/spring-aot-smoke-tests/data/hateoas/build/generated/aotSources/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration__BeanDefinitions.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
8 warnings