Commit Graph

1539 Commits

Author SHA1 Message Date
Sam Brannen 593bd064e1 Polishing 2022-08-25 13:23:04 +02:00
Stephane Nicoll 5aa8583159 Add shortcut to register an executable with a mode
See gh-29011
2022-08-24 19:32:02 +02:00
Stephane Nicoll c164b918c0 Apply consistent RuntimeHints defaults
This commit harmonizes the registration of an executable so that
the default method and the method that takes an empty customizer
produces the same hint. The same applies to the readable flag of
a field hint.

Rather than returning a list of executable modes, the "highest" mode
is retained.

See gh-29011
2022-08-24 19:32:01 +02:00
Stephane Nicoll c6bcf79c0e Add hint for use of Qualifier in meta-annotations
Closes gh-29000
2022-08-23 14:31:09 +02:00
Stephane Nicoll 455715899d Infer proxy on `@Lazy`-annotated injection points
This commit makes use of the new `getLazyResolutionProxyClass` on
`AutowireCandidateResolver` to detect if a injection point requires
a proxy.

Closes gh-28980
2022-08-22 20:48:02 +02:00
Stephane Nicoll 40de029bf8 Polish 2022-08-22 16:32:53 +02:00
Juergen Hoeller 4eb84a0537 Introduce getLazyResolutionProxyClass mechanism in AutowireCandidateResolver SPI
See gh-28980
2022-08-22 16:24:37 +02:00
Juergen Hoeller 427e5f5899 Final merged bean definition clearing in freezeConfiguration
Instead of individual last-minute clearing in markBeanAsCreated, the factory clears all merged bean definitions in freezeConfiguration, retaining the changes of merged bean definition post-processing after that point (in particular in refreshForAotProcessing).

Closes gh-28948
2022-08-19 17:30:59 +02:00
Stephane Nicoll 4f0c879778 Rationalize hints required for annotations
This commit updates RuntimeHintsUtils to focus on registering a JDK
proxy only as annotations of annotated elements that have at least
an introspection hints are visible out-of-the-box.

This commit also removes unnecessary hints and adapt `@Reflective` to
detect if a hint is required using the introduced
MergedAnnotation#isSynthesizable.

See gh-28967
2022-08-16 15:42:52 +02:00
Juergen Hoeller 38c9e7f629 Polishing 2022-08-10 23:30:27 +02:00
Juergen Hoeller b31a15851e Support for pre-generated CGLIB proxy classes (in AOT scenarios)
Includes runtime storing of generated classes to a directory specified by the "cglib.generatedClasses" system property. Avoids lazy CGLIB fast-class generation and replaces generated Enhancer and MethodWrapper key classes with equivalent record types. Introduces support for early type determination in InstantiationStrategy, AopProxy and SmartInstantiationAwareBeanPostProcessor - in order to trigger CGLIB class generation in refreshForAotProcessing (through early determineBeanType calls for bean definitions).

Closes gh-28115
2022-08-10 23:30:19 +02:00
Stephane Nicoll 0a9db7cc47 Revert "Make sure inferred destroy method is set on the original bean definition"
This reverts commit 2e1538a20b.
2022-08-09 11:31:56 +02:00
Stephane Nicoll 2e1538a20b Make sure inferred destroy method is set on the original bean definition
This commit updates InitDestroyAnnotationBeanPostProcessor to mutate
the original bean definition rather than the merged one that can be
recreated without it if the cache gets stale.

See gh-28215
2022-08-08 14:33:00 +02:00
Stephane Nicoll 3c76437868 Update RegisteredBean to take a ConfigurableListableBeanFactory
This allows to have access to `getBeanDefinition` if the original
bean definition needs to be retrieved.

See gh-28936
2022-08-08 14:00:49 +02:00
Stephane Nicoll 832889d801 Polish 2022-08-08 11:31:38 +02:00
Stephane Nicoll dcad3beeb9 Polish 2022-08-03 11:03:28 +02:00
Stephane Nicoll c9faff7491 Apply property hints to FactoryBean if necessary
This commit handles a BeanDefinition that configures the FactoryBean
as the "beanClass", while exposing the actual type in "resolvedType".
While unusual, this is required in certain cases when the factory
bean exposes generic information itself.

Previously, the hints for properties injection were applied on the
user type.

Closes gh-28913
2022-08-03 10:58:41 +02:00
Stephane Nicoll e79a8f6733 Polish 2022-08-03 10:53:57 +02:00
Sam Brannen ad99add429 Polish AOT support 2022-07-30 10:51:14 +03:00
Stephane Nicoll 8e7faab4f6 Polish 2022-07-28 16:37:08 +02:00
Phillip Webb 24fafc2fb7 Document that AOT processors are initialized during AOT processing
Closes gh-28866
2022-07-28 14:30:26 +01:00
Phillip Webb 9413383d72 Enforce BeanRegistrationExcludeFilter beans are also AOT processors
Update `BeanDefinitionMethodGeneratorFactory` to enforce that any
`BeanRegistrationExcludeFilter` filter that is from a bean factory
also implements an AOT processor interface.

See gh-28866
2022-07-28 14:29:28 +01:00
Phillip Webb a4f3d1d6e8 Track the sources used to load AOT services
Update `AotServices` so that it tracks which source was used to
provide a given instance.

See gh-28866
2022-07-28 14:28:37 +01:00
Phillip Webb 5218cf4c16 Fix BeanFactoryInitializationAotProcessor javadoc
Update javadoc since BeanRegistrationExcludeFilter is not longer an
exclude signal

See gh-28833
2022-07-28 14:25:56 +01:00
Phillip Webb e928943d1a Don't use BeanRegistrationExcludeFilter as an exclude signal
Closes gh-28833
2022-07-27 19:26:11 +01:00
Phillip Webb 472c23455a Add AotServices class to replace AotFactoriesLoader
Add an `AotServices` class to replace `AotFactoriesLoader`. The
replacement class allow instances to be loaded from just the
`aot.factories` file if required. It also retains a link to the bean
names so that a `findByBeanName(...)` method can be provided.

See gh-28833
2022-07-27 19:25:28 +01:00
Stephane Nicoll 88e29689b6 Polish 2022-07-27 15:10:09 +02:00
Stephane Nicoll f0f7f72de9 Do not write BeanDefinition attributes by default
This commit flips the default strategy for BeanDefinition attributes so
that they are not generated in AOT-optimized contexts.

Closes gh-28516
2022-07-27 15:01:50 +02:00
Stephane Nicoll 735051bf7d Resolve infer destroy method at build-time
This commit allows a RootBeanDefinition to resolve its infer destroy
method if necessary. Contrary to BeanInstanceAdapter that uses the
actual bean instance, the new method works against the type exposed
in the bean definition.

The AOT contribution of InitDestroyAnnotationBeanPostProcessor uses
the new method to make sure the special '(inferred)' placeholder is
handled prior to code generation.

Closes gh-28215
2022-07-27 11:48:13 +02:00
Stephane Nicoll 3d5003ad63 Introduce TestGenerationContext
This commit polishes DefaultGenerationContext to make the method
that flushes generated classes more explicit. It now throws an
IOException and TestGenerationContext has been updated to handle
that to ease its use in code that can't throw such an exception.

As this use case is likely to happen outside the Spring Framework,
this commit adds such a convenience to spring-test as well.

Closes gh-28877
2022-07-26 17:56:17 +02:00
Stephane Nicoll 60d2d16b2b Polish 2022-07-26 15:18:35 +02:00
Stephane Nicoll c1738aab0d Improve target detection for FactoryBeans with generic
Closes gh-28809
2022-07-22 13:10:44 +02:00
Stephane Nicoll bbcc269487 Polish 2022-07-22 12:09:16 +02:00
Stephane Nicoll c09eb633db Rename test fixture to avoid class with existing TestBean class 2022-07-22 12:03:00 +02:00
Stephane Nicoll ba5ab1ad9d Polish 2022-07-22 09:36:45 +02:00
Phillip Webb cfb61d2a17 Add generics to BeanInstanceSupplier
Update `BeanInstanceSupplier` to support a generic type.

See gh-28748
2022-07-21 13:29:15 +01:00
Phillip Webb 069d6d3280 Propagate getFactoryMethod() when using InstanceSupplier.andThen()
Update `InstanceSupplier.andThen` to propagate the result of
`getFactoryMethod()`.

See gh-28748
2022-07-20 18:56:57 +01:00
Phillip Webb 3ae1b9ba57 Polish CodeBlock joining logic
Consistently use `CodeBlock.joining(", ")` when generating code.
2022-07-20 10:25:45 +01:00
Stephane Nicoll 85173b5de3 Polish "Handle inferred init/destroy method consistently"
See gh-28843
2022-07-20 10:45:51 +02:00
Olga Maciaszek-Sharma 68e28a5f59 Handle inferred init/destroy method consistently
See gh-28843
2022-07-20 10:40:51 +02:00
Stephane Nicoll d6345db7c9 Use target of the FactoryBean only if the FactoryBean is public
This commit polishes 85d4a79 so that the target type of factory bean
is only considered if the FactoryBean is accessible. If the FactoryBean
requires protected access, we still generate the code in the package of
the FactoryBean.

Those two commits combined are actually providing a fix for the use
case described in gh-28809.

Closes gh-28809
2022-07-19 21:02:24 +02:00
Stephane Nicoll 978cdfff46 Formatting 2022-07-19 17:57:28 +02:00
Stephane Nicoll 1acb41ff43 Add AOT support for by-type RuntimeBeanReference
Closes gh-28841
2022-07-19 17:57:12 +02:00
Stephane Nicoll 85d4a79cdc Improve location of generated bean definitions of FactoryBeans
This commit improves the location of generated bean definitions for
FactoryBean implementations by checking the type that the factory
bean generates, rather than the factory bean implementation itself.

Closes gh-28812
2022-07-19 15:17:31 +02:00
Phillip Webb 578f155809 Polishing 2022-07-18 15:01:51 +01:00
Phillip Webb 87b83e8291 Make MethodName package-private
Closes gh-28832
2022-07-18 11:20:43 +01:00
Phillip Webb 0ea4ee163c Polishing 2022-07-18 10:54:30 +01:00
Stephane Nicoll 75ab47b57c Link factoryMethod consistently in AOT-generated bean definitions
Closes gh-28748
2022-07-18 10:06:48 +01:00
Phillip Webb f2d31b7a20 Migrate AOT tests to use GeneratedClasses and refine/polish AOT APIs
Migrate all AOT tests to make use of `GeneratedClasses` rather than
directly generating Java files. This commit also refines and polishes
AOT APIs to being greater consistency.

Specifically:

	- The `MethodGenerator` interface has been removed in favor of
	  working directly with `GeneratedMethods`.
	- The visibility of several constructors and methods has been
	  reduced to package-private.
	- The `using(...)` and `builder` methods have been removed in
	  favor of setting the `Consumer` callbacks directly as
	  constructor arguments.
	- Variable names for builders are now named `type` or `method`
	  depending on what they're building.

Closes gh-28831
2022-07-18 08:40:59 +01:00
Sam Brannen 1f3ea5133f Polishing 2022-07-15 15:28:47 +02:00