closes gh-30755

Comment From: bdshadow

I understand that InitDestroyAnnotationBeanPostProcessorTests must be improved further (and i'm ready to do it), but anyway made a mr to discuss if the whole idea of the fix is correct

As Sam wrote here https://github.com/spring-projects/spring-framework/pull/30724#issuecomment-1602534343, the problem was indeed in merging init/destroy method names during AOT processing and then there're treated equally in runtime, however it's not true in non-aot mode. Because @PostConstruct annotations are considered externallyManaged and are processed differently. So i think the correct solution is to register CommonAnnotationBeanPostProcessor (or other InitDestroyAnnotationBeanPostProcessor-s) when they're used.

Comment From: snicoll

Thanks for the PR. Unfortunately, I don't think we should register the post-processor. It's a bit backwards as the AOT processing is meant to replace the post-processor by some optimized code.

Removing the method names from the generated code is also not something we'd like to pursue. Ideally the full list of methods to invoke would be in generated code, and the distinction with externally managed would not exist. I haven't looked at the problem enough to know if that's possible without changing something in the core container.

With that said, do you want to continue working on this or should we close this?

Comment From: snicoll

Alright I am going to close this now as this approach is not what we'd consider to fix the related issue. Thanks for the PR, in any case!