Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support [package-]private init/destroy methods in AOT mode #30724

Commits on Jun 23, 2023

  1. Support [package-]private init/destroy methods in AOT mode

    Prior to this commit, private (and non-visible package-private)
    init/destroy methods were not supported in AOT mode. The reason is that
    such methods are tracked using their fully-qualified method names, and
    the AOT support for init/destroy method previously did not take
    fully-qualified method names into account. In addition, the invocation
    order of init/destroy methods differed between standard JVM mode and
    AOT mode.
    
    This commit addresses these issues in the following ways.
    
    - AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(),
      DisposableBeanAdapter.determineDestroyMethod(), and
      BeanDefinitionPropertiesCodeGenerator.addInitDestroyHint() now parse
      fully-qualified method names to locate the correct init/destroy
      methods.
    
    - AbstractAutowireCapableBeanFactory and DisposableBeanAdapter delegate
      to a new MethodDescriptor record which encapsulates the parsing of
      fully-qualified method names; however,
      BeanDefinitionPropertiesCodeGenerator duplicates this logic since it
      resides in a different package, and we do not currently want to make
      MethodDescriptor public.
    
    - Init/destroy methods detected via annotations (such as @PostConstruct
      and @PreDestroy) are now invoked prior to init/destroy methods that
      are explicitly configured by name or convention. This aligns with the
      invocation order in standard JVM mode; however,
      InitializingBean#afterPropertiesSet() and DisposableBean#destroy()
      are still invoked before annotated init/destroy methods in AOT mode
      which differs from standard JVM mode.
    
    - Unit and integration tests have been updated to test the revised
      behavior.
    
    Closes spring-projectsgh-30692
    
    f
    sbrannen committed Jun 23, 2023
    Copy the full SHA
    066dfe3 View commit details
    Browse the repository at this point in the history