Commit Graph

2147 Commits

Author SHA1 Message Date
Stéphane Nicoll 52849819de Detect deprecation on enclosing classes as well
This commit improves CodeWarnings so that it detects if an enclosing
class is deprecated. Previously, it would only consider the annotated
element itself and the enclosing element is important for a class as
it is required to refer to it.

Closes gh-33273
2024-07-25 16:28:40 +02:00
Stéphane Nicoll e741d6edbb Exclude bean definition from AOT processing using an attribute
This commits allows a particular bean definition to be excluded from
AOT processing using an attribute.

If BeanRegistrationAotProcessor#IGNORE_REGISTRATION_ATTRIBUTE is set
to `true`, then the bean definition is excluded. This complement the
existing BeanRegistrationExcludeFilter capability.

Closes gh-33243
2024-07-24 12:42:45 +02:00
Stéphane Nicoll d219362eb1 Keep fallback flag in AOT-generated code
Closes gh-33261
2024-07-23 11:30:37 +02:00
Stéphane Nicoll 30a64d6a0b Avoid code too large with AOT processing
This commit adapts code generation to "slice" the registration of bean
definitions in separate bean methods rather than a unique method for
all of them.

If the bean factory has more than a thousand bean, a method is created
for each slice of 1000 bean definitions.

Closes gh-33126
2024-07-17 16:04:32 +02:00
Juergen Hoeller 8cfdaaaabc Merge branch '6.1.x' 2024-07-10 15:57:24 +02:00
Juergen Hoeller f2b3263fff Polishing 2024-07-10 15:56:56 +02:00
Stéphane Nicoll 6de624d537 Provide a template method to expose the currently invoked factory method
This commit improves SimpleInstantiationStrategy by providing a common
template method before the regular runtime and AOT. As a result, the
method to set the currently invoked factory method is deprecated as it
should no longer be used.

Closes gh-33192
2024-07-10 15:38:17 +02:00
Juergen Hoeller a9efe10428 Merge branch '6.1.x'
# Conflicts:
#	spring-beans/src/main/java/org/springframework/beans/factory/aot/DefaultBeanRegistrationCodeFragments.java
2024-07-10 15:16:40 +02:00
Juergen Hoeller 3ccaefe38f Polishing 2024-07-10 15:15:32 +02:00
Stéphane Nicoll c6b20c04c2 Merge branch '6.1.x' 2024-07-10 12:39:05 +02:00
Stéphane Nicoll b5a86dec92 Retain previous factory method in case of nested invocation with AOT
This commit harmonizes the invocation of a bean supplier with what
SimpleInstantiationStrategy does. Previously, the current factory method
was set to `null` once the invocation completes. This did not take
into account recursive scenarios where an instance supplier triggers
another instance supplier.

For consistency, the thread local is removed now if we attempt to set
the current method to null. SimpleInstantiationStrategy itself uses
the shortcut to align the code as much as possible.

Closes gh-33180
2024-07-10 12:38:56 +02:00
Juergen Hoeller 384d0e4fd5 Merge branch '6.1.x' 2024-07-03 16:37:36 +02:00
Juergen Hoeller daea3f0eae Apply fallback resolution for non-hierarchical URIs such as "file:."
Includes meaningful exception message for file system resolution.

Closes gh-33124
2024-07-03 16:36:18 +02:00
Sam Brannen 932ce04541 Stop referring to old Spring versions in Javadoc 2024-07-01 17:50:52 +02:00
Juergen Hoeller 775a23b39d Merge branch '6.1.x' 2024-06-28 18:10:53 +02:00
Juergen Hoeller 61adf2dd25 Formal null safety for exception message through String.valueOf
See gh-33117
2024-06-28 18:09:39 +02:00
Juergen Hoeller 61894af0bd Expose FactoryBean attribute exception as BeanDefinitionStoreException
Closes gh-33117
2024-06-28 17:55:45 +02:00
Juergen Hoeller 52e1f30bfe Merge branch '6.1.x' 2024-06-20 13:48:55 +02:00
Juergen Hoeller 2861e570fd Catch and log LinkageError in getTypeForFactoryMethod
Closes gh-33075
2024-06-20 13:47:43 +02:00
Juergen Hoeller 1047e1f722 Declare complete set of default methods on ObjectProvider
Closes gh-33070
2024-06-19 16:53:10 +02:00
Juergen Hoeller a58e27eded Use CollectionFactory#newLinkedHashSet for method arguments
See gh-32291
2024-06-17 18:50:31 +02:00
Stéphane Nicoll 4fac6a91c7 Merge branch '6.1.x' 2024-06-13 14:10:53 +02:00
Stéphane Nicoll d0aa7ad524 Fix invalid character in Javadoc of BeanFactory 2024-06-13 14:06:19 +02:00
Juergen Hoeller 28eb9aebcf Add BeanFactoryInitializer callback before preInstantiateSingletons
Closes gh-32836
2024-06-04 22:50:42 +02:00
Stéphane Nicoll 42ace2c2c9 Provide dedicated AOT exception hierarchy
This commit adds a number of catch point that provides additional
context when an AOT processor fails to execute. Amongst other things,
this makes sure that the bean name and its descriptor is consistently
provided in the error message when available.

Closes gh-32777
2024-06-04 09:36:21 +02:00
Stéphane Nicoll 6a761412a8 Simplify BeanRegistrationsAotProcessor
Closes gh-32944
2024-06-03 16:01:12 +02:00
Juergen Hoeller 5a275443b5 Apply ThreadLocal#remove() to pre-instantiation threads
See gh-13410
See gh-32874
2024-05-28 16:35:58 +02:00
Sam Brannen 870d15c0b6 Merge branch '6.1.x' 2024-05-27 16:44:19 +02:00
Sam Brannen 8feb842df5 Upgrade to AssertJ 3.26.0
See https://github.com/assertj/assertj/issues/3322
2024-05-27 16:43:22 +02:00
Juergen Hoeller 49caa02584 Merge branch '6.1.x' 2024-05-24 13:06:21 +02:00
Juergen Hoeller 26d1c38d84 Polishing 2024-05-24 13:05:49 +02:00
Juergen Hoeller dae4366325 Merge branch '6.1.x' 2024-05-24 11:55:53 +02:00
Juergen Hoeller 345daaabbc Detect original generic method for CGLIB bridge method
Closes gh-32888
2024-05-24 11:49:10 +02:00
Stéphane Nicoll ddf5521bc9 Merge branch '6.1.x' 2024-05-21 08:56:41 +02:00
Stéphane Nicoll f26483d272 Detect deprecated element in generic types
This commit updates Spring AOT to suppress a deprecation warning for
a generic type that has a deprecated element. Previously we only were
checking for the raw class.

Closes gh-32850
2024-05-21 08:53:18 +02:00
Juergen Hoeller 28398624bf Avoid cyclic package import for javadoc reference 2024-05-15 22:19:20 +02:00
Brian Clozel f7a6a7b814 Allow ReflectionHints to register hints on interface hierarchies
This commit promotes a previously private method in
`BeanRegistrationsAotContribution` to a top-level method in
`ReflectionHints`.

This helps to register hints on all interfaces implemented in the class
hierarchy of the given type.

Closes gh-32824
2024-05-14 17:54:12 +02:00
Sam Brannen f629fc9dc5 Polish Javadoc for SmartInstantiationAwareBeanPostProcessor 2024-05-11 16:13:26 +02:00
Sébastien Deleuze 7985ab33f4 Throw an exception for suspending factory methods
Suspending factory methods are not supported, and can
have side effects, so it is better to fail explicitly
for such use case.

Closes gh-32719
2024-05-10 11:56:50 +02:00
Stéphane Nicoll 2d942a6e91 Merge branch '6.1.x' 2024-05-08 10:30:19 +02:00
Stéphane Nicoll 5b1278d03c Refine exception message to include bean name
Closes gh-32775
2024-05-08 10:27:34 +02:00
Juergen Hoeller 69eaf8f828 Merge branch '6.1.x' 2024-05-01 18:07:13 +02:00
Juergen Hoeller 25cedcfb99 Consistently propagate ApplicationStartup to BeanFactory
Closes gh-32747
2024-05-01 18:06:27 +02:00
Juergen Hoeller f1a1190700 Merge branch '6.1.x'
# Conflicts:
#	framework-docs/modules/ROOT/pages/data-access/transaction/declarative/annotations.adoc
2024-04-30 15:47:48 +02:00
Juergen Hoeller cbda46984c Polishing 2024-04-30 15:46:28 +02:00
Juergen Hoeller dfc053ad65 Merge branch '6.1.x'
# Conflicts:
#	framework-platform/framework-platform.gradle
2024-04-29 18:05:40 +02:00
Juergen Hoeller 3cf2cd70ab Polishing 2024-04-29 18:02:44 +02:00
Juergen Hoeller 0ac04a7f86 Include original exception message in dependency initialization exception
Closes gh-32470
2024-04-29 18:02:39 +02:00
Juergen Hoeller 0402ea13c0 Merge branch '6.1.x' 2024-04-24 13:42:43 +02:00
Juergen Hoeller 387e34d881 Wrap depends-on exception for specifically requested top-level bean
Closes gh-32470
2024-04-24 13:41:48 +02:00
Stéphane Nicoll 8124491249 Merge branch '6.1.x' 2024-04-22 17:01:04 +02:00
Stéphane Nicoll c99e7f8616 Ignore InstanceSupplier for getBean with arguments
Previously, a BeanDefinition that has an instance supplier would be
used irrespective of custom arguments being provided. This commit only
applies the instance supplier if no arguments are provided. With
custom arguments, the regular lookup takes place based on the
information provided in the bean factory.

Closes gh-32657
2024-04-22 16:59:31 +02:00
Stéphane Nicoll c21090ad31 Merge branch '6.1.x' 2024-04-22 15:16:50 +02:00
Stéphane Nicoll 8a8c8fe00e Detect target of factory method with AOT
Previously, if a factory method is defined on a parent, the generated
code would blindly use the method's declaring class for both the target
of the generated code, and the signature of the method.

This commit improves the resolution by considering the factory metadata
in the BeanDefinition.

Closes gh-32609
2024-04-22 15:13:56 +02:00
Juergen Hoeller e42c5ca52b Merge branch '6.1.x' 2024-04-18 12:20:14 +02:00
Juergen Hoeller 0e0397a385 Polishing 2024-04-18 12:18:18 +02:00
Sam Brannen 69cb2a347a Update copyright date
See gh-32647
2024-04-16 15:11:12 +02:00
janghs 0d4ef4eafe Omit empty resource description in DeprecatedBeanWarner's log message
Closes gh-32647
2024-04-16 15:07:18 +02:00
Juergen Hoeller 4eb93da31d Merge branch '6.1.x'
# Conflicts:
#	spring-beans/src/main/java/org/springframework/beans/factory/support/GenericTypeAwareAutowireCandidateResolver.java
2024-04-08 22:41:02 +02:00
Juergen Hoeller f2889b1b43 Consistent support for generic FactoryBean type matching
Closes gh-32590
See gh-32489
2024-04-08 22:39:29 +02:00
Juergen Hoeller 13df59cef4 Merge branch '6.1.x' 2024-04-08 09:52:42 +02:00
Juergen Hoeller 22328905da Do not extract FactoryBean generic in case of targetType mismatch
Closes gh-32489
2024-04-08 09:51:59 +02:00
Sébastien Deleuze 0c42874629 Merge branch '6.1.x' 2024-04-05 14:33:20 +02:00
Sébastien Deleuze 4a7c24d90f Refine null-safety
See gh-32475
2024-04-05 14:30:50 +02:00
Stéphane Nicoll 7a74e45946 Make use of bean definition overriding more visible
This commit makes the use of bean definition overriding more visible and
prepare for a deprecation of the feature in the next major release.

As of this commit, use of bean definition overriding logs at INFO level.
The previous log level can be restored by setting the
allowBeanDefinitionOverriding flag explicitly on the BeanFactory (or
via the related ApplicationContext).

A number of tests that are using bean overriding on purpose have been
updated to set this flag, which will make them easier to find once we
actually deprecate the feature.

Closes gh-31288
2024-04-02 14:05:12 +02:00
Sébastien Deleuze 5b660da52d Perform NullAway build-time checks in more modules
This commit enables null-safety build-time checks in:
 - spring-jdbc
 - spring-r2dbc
 - spring-orm
 - spring-beans
 - spring-aop

See gh-32475
2024-03-26 09:59:30 +01:00
Sébastien Deleuze 3b4f8dbb8e Merge branch '6.1.x' 2024-03-26 09:47:09 +01:00
Sébastien Deleuze 1b563f8ba4 Refine null-safety in more modules
This commit refines the null-safety in:
 - spring-jdbc
 - spring-r2dbc
 - spring-orm
 - spring-beans
 - spring-aop

See gh-32475
2024-03-26 09:46:34 +01:00
Felix 05b15812bb Apply instanceof pattern matching in RootBeanDefinition
Closes gh-32520
2024-03-23 09:09:25 +01:00
Stéphane Nicoll cf4ac96688 Merge branch '6.1.x' 2024-03-22 16:33:17 +01:00
Juergen Hoeller e58ea0d945 Merge branch '6.1.x'
# Conflicts:
#	spring-core/src/main/java/org/springframework/core/CoroutinesUtils.java
2024-03-19 10:06:48 +01:00
Juergen Hoeller c531a8a705 Nullability refinements and related polishing
See gh-32475
2024-03-19 09:58:44 +01:00
Sam Brannen e1b1435a00 Stop referring to JDK 1.5 plus polishing 2024-03-14 16:00:51 +01:00
Sam Brannen 04e69bdb26 Polish contribution
Closes gh-32412
2024-03-11 17:04:53 +01:00
Mikaël Francoeur 3e48031601 Reject null return value from MethodReplacer for primitive return type
This commit throws an exception instead of silently converting a null
return value from a MethodReplacer to a primitive 0/false value.

See gh-32412
2024-03-11 17:04:53 +01:00
Sam Brannen f285971cb3 Polishing 2024-03-11 17:04:53 +01:00
Stéphane Nicoll e53ed3e3c6 Merge branch '6.1.x' 2024-03-09 16:03:04 +01:00
Stéphane Nicoll 4983a802a7 Polish "Fix Javadoc"
See gh-32403
2024-03-09 16:02:01 +01:00
Maksim Sasnouski abdccffa39 Fix Javadoc
This commit fixes various Javadoc issues across the code base.

See gh-32403
2024-03-09 16:02:00 +01:00
Sam Brannen 20be9e150c Polishing 2024-03-09 14:28:01 +01:00
Juergen Hoeller fad544e077 Merge branch '6.1.x'
# Conflicts:
#	spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java
2024-03-08 19:51:05 +01:00
Juergen Hoeller c1287d48e2 Polishing 2024-03-08 19:31:01 +01:00
Sam Brannen ae6c64abc5 Fix Javadoc errors 2024-03-08 11:59:53 +01:00
Juergen Hoeller c9e85ec297 Introduce callback for singleton availability
Closes gh-21362
2024-03-07 09:57:29 +01:00
Juergen Hoeller 14a461e795 Consider type-level qualifier annotations for transaction manager selection
Closes gh-24291
2024-03-06 13:36:33 +01:00
Juergen Hoeller b5ca646431 Leniently tolerate late bean retrieval during destroySingletons()
Closes gh-22526
Closes gh-29730
2024-03-04 17:21:02 +01:00
Yanming Zhou 246ebd24bf Add missing method BeanDefinitionBuilder.setFallback() 2024-02-29 13:34:55 +01:00
Sébastien Deleuze 7c5bcbcba4 Merge branch '6.1.x' 2024-02-28 17:24:08 +01:00
Sébastien Deleuze 45c21042f6 Optimize Kotlin inline class checks
This commit fixes a performance regression caused by gh-31698,
and more specifically by KClass#isValue invocations which are slow since
they load the whole module to find the class to get the descriptor.

After discussing with the Kotlin team, it has been decided that only
checking for the presence of `@JvmInline` annotation is enough for
Spring use case.

As a consequence, this commit introduces a new
KotlinDetector#isInlineClass method that performs such check, and
BeanUtils, CoroutinesUtils and WebMVC/WebFlux InvocableHandlerMethod
have been refined to leverage it.

Closes gh-32334
2024-02-28 17:18:57 +01:00
Juergen Hoeller aeb77cf4e1 Restore correct threadWithLock check without isInfoEnabled()
See gh-23501
2024-02-28 11:47:39 +01:00
Juergen Hoeller 17b2087198 Introduce background bootstrapping for individual singleton beans
Closes gh-13410
Closes gh-19487
See gh-23501
2024-02-27 22:33:18 +01:00
Juergen Hoeller 4d206f79d0 Merge branch '6.1.x'
# Conflicts:
#	spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java
2024-02-26 13:42:00 +01:00
Juergen Hoeller 479879c53a Polishing 2024-02-26 13:40:21 +01:00
Juergen Hoeller 2e57603310 Try type conversion for unique fallback write method as well
Closes gh-32329
See gh-32159
2024-02-26 13:40:05 +01:00
Juergen Hoeller 567547b63c Skip shortcut resolution for non-standard dependency descriptors
Closes gh-32326
See gh-28122
2024-02-24 18:05:23 +01:00
Juergen Hoeller 58b8330e8d Consistent documentation of defaults and related methods
See gh-32308
2024-02-23 14:41:37 +01:00
Sam Brannen b0d08fe2d4 Spring cleaning: avoid deprecation warnings 2024-02-23 12:38:40 +01:00
Sam Brannen 122372c580 Spring cleaning: update copyright headers 2024-02-23 12:21:22 +01:00
Sam Brannen 4339c8eac2 Spring cleaning: use diamond operator 2024-02-23 12:20:11 +01:00
Juergen Hoeller 3ddc512108 Add missing @Override annotations 2024-02-22 11:21:51 +01:00