Commit Graph

2447 Commits

Author SHA1 Message Date
Phillip Webb 505da5c602 Migrate hint registration to shortcuts
Migrate code to make use of the `MemberCategory` and `FieldMode`
shortcuts.

See gh-29011
2022-09-01 17:26:06 -07: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
Stephane Nicoll 8a51e31069 Make sure that AnnotationAwareOrderComparator is configured with AOT
Closes gh-28988
2022-08-22 14:18:42 +02:00
Juergen Hoeller 9b2a40a3bc Lazy Validator resolution in MethodValidationPostProcessor
Closes gh-28990
2022-08-22 14:07:42 +02:00
Sébastien Deleuze daf2d940e4 Remove specific JDK dynamic proxy configuration
Further refinements will be required for
MethodValidationPostProcessor since @Lazy
used by Spring Boot is not supported yet
for that use case.

See gh-28980
2022-08-22 10:53:12 +02:00
Sébastien Deleuze ebf6de8f5d Infer JDK dynamic proxies for Spring beans
See gh-28980
2022-08-22 07:58:15 +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 4556895e6e Expose registrar for @Reflective
This commit exposes the logic of processing `@Reflective` on beans so
that it can be reused in custom arrangements.

Closes gh-28975
2022-08-17 14:33:09 +02:00
Sébastien Deleuze 06d9db154e Introduce CachingBeanRegistrationAotProcessor
It contributes proxy hints for interfaces when class
proxying is not forced.

Closes gh-28943
2022-08-17 11:38:12 +02:00
Sébastien Deleuze 491b7771d0 Register proper caching annotation runtime hints
See gh-28943
2022-08-17 11:36:24 +02:00
Stephane Nicoll 494bca727f Disable RuntimeHints tests with the agent
Tests with the agent are broken now that hints for an annotation is
no longer required if the annotated element has an introspection hint.

See gh-28967
2022-08-16 15:42:52 +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
Stephane Nicoll 9a1b7c5e47 Allow target type of a cglib proxy to be visible
This commit updates the hints of a Cglib proxy's target type so that
methods can be invoked and constructors can be introspected. The former
is needed as a cglib proxy invokes the target type via reflection. As
for that latter, this is required at least by
Enhancer#filterConstructors.

See gh-28954
2022-08-16 08:30:37 +02:00
Stephane Nicoll 6ba31acf35 Polish "Add support for Async invocation in a native image"
This registers the hints if the annotation post processor is active,
rather than statically.

See gh-28710
2022-08-12 17:43:48 +02:00
Stephane Nicoll 0229cc45a0 Add support for Async invocation in a native image
This commit adds necessary hints so that Async-annotated method can be
discovered in a native image.

Closes gh-28710
2022-08-12 16:34:13 +02:00
Stephane Nicoll 3086d90e7d Add the necessary hints for use of Cglib proxies
This commit expands GeneratedClassHandler to allow invocation of
declared fields and methods. Generated proxies have a number of
internal fields and methods that are invoked via reflection.

See gh-28954
2022-08-12 16:27:10 +02:00
Stephane Nicoll 7c2453c373 Integrate class proxy generation in AOT processing
This commit updates ApplicationContextAotGenerator to register a
handler that process Cglib generated classes. The handler registers
such classes to the GeneratedFiles and provide a hint so that it
can be instantiated using reflection.

Closes gh-28954
2022-08-12 12:17:13 +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 005713066c Freeze configuration before invoking MBDPP instances
This commit updates refresh for AOT processing so that the configuration
is frozen before invoking MergedBeanDefinitionPostProcessor instances.
This makes sure that post-processed MergedBeanDefinitions are kept in
cache and not lost if a component attempts to clear the metadata cache.

Closes gh-28941
2022-08-09 13:29:14 +02:00
Sam Brannen 1e8bc1b0fb Polishing 2022-08-06 14:42:19 +03:00
Sam Brannen 7d364bba72 Clean up warnings 2022-08-06 14:41:54 +03:00
Sam Brannen 1de0207874 Rename tests due to change in gh-28927 2022-08-05 13:59:14 +03:00
Sam Brannen 853407b6f8 Polishing 2022-08-05 13:57:28 +03:00
Stephane Nicoll 2cc4486e3d Rename ApplicationContextAotGenerator entry point
Closes gh-28927
2022-08-05 10:19:06 +02:00
Stephane Nicoll e50db8c8c5 Make sure that ImportAwareAotBeanPostProcessor has role infrastructure
See gh-28915
2022-08-04 09:37:17 +02:00
Stephane Nicoll 332d4a4c9c Apply same order than original BPP
This commit updates ImportAwareAotBeanPostProcessor to be priority
ordered, with the same order as its original BeanPostProcessor. This
makes sure that infrastructure beans can be post-processed if
necessary

See gh-28915
2022-08-04 09:35:11 +02:00
Stephane Nicoll e5f9574800 Fix test
Contribution was not applied on the actual use case

See gh-28915
2022-08-04 09:32:45 +02:00
Stephane Nicoll 3a890033b7 Fix custom bean definition to stop using reflection
See gh-28915
2022-08-03 14:51:52 +02:00
Stephane Nicoll 1fdd91eb30 Restore order of setImportMetadata in AOT optimized contexts
This commit adapts the generated code for handling ImportAware to
register a bean definition rather than adding the BeanPostProcessor
directly on the beanFactory. The previous arrangement put the
post processor handling import aware callbacks first on the list,
leading to inconsistent callback orders.

Tests have been adapted to validate this exact scenario.

Closes gh-28915
2022-08-03 10:16:20 +02:00
Sam Brannen b0ab0edd9d Polishing 2022-08-02 13:07:12 +03:00
Sam Brannen e4395f2f8b Clean up warnings and polishing 2022-07-31 14:14:56 +03:00
Sam Brannen ad99add429 Polish AOT support 2022-07-30 10:51:14 +03:00
Stephane Nicoll 11d790c6eb Merge branch '5.3.x' 2022-07-29 18:07:37 +02:00
Stephane Nicoll 04209def46 Polish "Improve documentation of Cacheable"
Apply the same improvements to CacheEvict and CachePut.

See gh-28183
2022-07-29 18:04:23 +02:00
luvarqpp 3a61930bd0 Improve documentation of Cacheable
See gh-28183
2022-07-29 17:57:15 +02:00
Phillip Webb d33c2b52cc Don't look for RuntimeHintsRegistrar beans
Update `RuntimeHintsBeanFactoryInitializationAotProcessor` so
that `RuntimeHintsRegistrar` beans are not loaded.

See gh-28866
2022-07-27 19:26:12 +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
Arjen Poutsma 2aa74c9121 Deprecate ListenableFuture in favor of CompletableFuture
This commit deprecates ListenableFuture in favor of CompletableFuture.
ListenableFuture was introduced in Spring Framework 4.0, when
CompletableFuture was not yet available. Spring now requires JDK 17, so
having our own type no longer seems necessary.

Major changes in this commit include:
- Deprecation of ListenableFuture and related types
  (ListenableFutureCallback, SettableListenableFuture, etc.)
- Deprecation of AsyncListenableTaskExecutor in favor of default methods
  in AsyncTaskExecutor (submitCompletable).
- AsyncHandlerMethodReturnValueHandler now has toCompletableFuture
  instead of toListenableFuture.
- WebSocketClient now has execute methods, which do the same as
  doHandshake, but return CompletableFutures (cf. the reactive
  WebSocketClient).

All other changes
- add an overloaded method that takes a CompletableFuture parameter
  instead of ListenableFuture, and/or
- add a method with a 'Async' suffix that returns a CompletableFuture
  instead of a ListenableFuture (connectAsync, sendAsync).

Closes gh-27780
2022-07-27 12:41:35 +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 ebe3b37298 Allow MergedBeanDefinitionPostProcessor to handle bean creation
This commit registers the MergedBeanDefinitionPostProcessor instances
on the BeanFactory processed for AOT purposes. This allows beans that
are created at build-time to be post-processed for low-level needs such
as initialization and autowiring.

Closes gh-28777
2022-07-26 09:25:11 +02: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 0fb9de5d0e Merge branch '5.3.x' 2022-07-13 16:36:01 +02:00
Marc Wrobel bd3499671c Fix typos in test code
This commit fixes typos in test class names, test method names, and
test variable names.

Closes gh-28807
2022-07-13 16:24:11 +02:00
Sam Brannen aae9050351 Merge branch '5.3.x'
# Conflicts:
#	spring-context/src/main/java/org/springframework/scheduling/annotation/Async.java
#	spring-context/src/testFixtures/java/org/springframework/context/testfixture/jndi/SimpleNamingContextBuilder.java
#	spring-core/src/main/java/org/springframework/core/BridgeMethodResolver.java
#	spring-core/src/main/java/org/springframework/util/MimeType.java
2022-07-13 14:55:30 +02:00