Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

Reduce the need for reflection by using functional configuration #386

Closed
sdeleuze opened this issue Nov 25, 2020 · 5 comments
Closed

Reduce the need for reflection by using functional configuration #386

sdeleuze opened this issue Nov 25, 2020 · 5 comments
Assignees
Milestone

Comments

@sdeleuze
Copy link
Contributor

Leveraging @dsyer work on https://github.com/spring-projects-experimental/spring-init. The scope is not to be 100% reflection-less but rather to limit the amount of reflection to lower the footprint and increase the compatibility. Reflection will typically remain for @Controller etc.

@sdeleuze sdeleuze added this to the 0.9.1 milestone Nov 25, 2020
sdeleuze added a commit to sdeleuze/spring-native that referenced this issue Jan 14, 2021
This commit is a refactoring that turns the remaining
static configuration files into proper annotation-based hints.

It also removes the functional mode which is not something we
want to maintain as it is. Refining the hints trigger combined
with future build time transformation such as spring-atticgh-386 should provide
the same functionality implicitly.

The rsocket sample is broken, the allowUnsafeAccess defined in
the hints seems not taken in account.

Closes spring-atticgh-216
Closes spring-atticgh-347
@sdeleuze
Copy link
Contributor Author

See related spring-projects/spring-framework#18353 (comment) comment.

@sdeleuze sdeleuze modified the milestones: 0.9.1, 0.9.2 Feb 26, 2021
@SentryMan
Copy link

So I'm a bit confused, will Spring-Init be merged with the AOT Plugin, or remain separate? I notice it hasn't been updated in a while.

@dsyer
Copy link
Contributor

dsyer commented Mar 31, 2021

Many of the ideas in Spring Init have been incorporated into the AOT plugin. It's not clear that Spring Init is adding very much at this point, so I suppose the answer is "we don't know". It might be slightly faster in a regular JVM still, but that's without doing much optimization of the AOT generated code. If you are actually using Spring Init and would like to provide feedback, no decision has been made, so go ahead.

@sdeleuze
Copy link
Contributor Author

The first bits have been introduced in https://github.com/spring-projects-experimental/spring-native/tree/0.11.x with the AOT generation of a ContextBootstrap which looks like that:

public class ContextBootstrap implements ApplicationContextInitializer<GenericApplicationContext> {
  public void initialize(GenericApplicationContext context) {
    context.registerBean("commandlinerunnerApplication", CommandlinerunnerApplication.class, CommandlinerunnerApplication::new);
    context.registerBean("CLR", CLR.class, CLR::new);
    org.springframework.boot.autoconfigure.ContextBootstrap.registerBasePackages(context);
    context.registerBean("org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration", PropertyPlaceholderAutoConfiguration.class, PropertyPlaceholderAutoConfiguration::new);
    context.registerBean("propertySourcesPlaceholderConfigurer", PropertySourcesPlaceholderConfigurer.class, () -> PropertyPlaceholderAutoConfiguration.propertySourcesPlaceholderConfigurer());
    org.springframework.boot.autoconfigure.aop.ContextBootstrap.registerClassProxyingConfiguration(context);
    org.springframework.boot.autoconfigure.aop.ContextBootstrap.registerForceAutoProxyCreatorToUseClassProxying(context);
    context.registerBean("org.springframework.boot.autoconfigure.aop.AopAutoConfiguration", AopAutoConfiguration.class, AopAutoConfiguration::new);
    // ...
  }
}

I will create more fine grained issues to track our progresses.

@sdeleuze
Copy link
Contributor Author

Let's close this one as the base mechanism is now used and continue with more 0.11 fine grained issues as we migrate other samples.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

5 participants