Commit Graph

2118 Commits

Author SHA1 Message Date
Johnny Lim 3ba9d35e22 Polish
Closes gh-33566
2024-09-20 10:58:37 +02:00
Juergen Hoeller a044357c31 Apply lenient locking fallback to singleton pre-instantiation phase only
Closes gh-33463
2024-09-11 14:09:57 +02:00
Sam Brannen d1920c0982 Merge branch '6.1.x' 2024-09-05 17:46:20 +02:00
Johnny Lim b7c7823315 Add @⁠since tag for CodeWarnings.detectDeprecation(ResolvableType)
See gh-32850
Closes gh-33493
2024-09-05 17:45:52 +02:00
Sam Brannen 717b972f88 Polish contribution
See gh-33452
2024-09-03 18:08:23 +02:00
Yanming Zhou 019c0b1d4e
Expand acronyms FQN and FQCN
Closes gh-33452
2024-09-03 17:30:27 +02:00
Sam Brannen 47f88e123f Invoke init/destroy/SpEL methods via public types whenever possible
Prior to this commit, when invoking init methods and destroy methods
for beans as well as methods within Spring Expression Language (SpEL)
expressions via reflection, we invoked them based on the "interface
method" returned from ClassUtils.getInterfaceMethodIfPossible(). That
works well for finding methods defined in an interface, but it does not
find public methods defined in a public superclass.

For example, in a SpEL expression it was previously impossible to
invoke toString() on a non-public type from a different module. This
could be seen when attempting to invoke toString() on an unmodifiable
list created by Collections.unmodifiableList(...). Doing so resulted in
an InaccessibleObjectException.

Although users can address that by adding an appropriate --add-opens
declaration, such as --add-opens java.base/java.util=ALL-UNNAMED, it is
better if applications do not have to add an --add-opens declaration
for such use cases in SpEL. The same applies to init methods and
destroy methods for beans.

This commit therefore introduces a new
getPubliclyAccessibleMethodIfPossible() method in ClassUtils which
serves as a replacement for getInterfaceMethodIfPossible().

This new method finds the first publicly accessible method in the
supplied method's type hierarchy that has a method signature equivalent
to the supplied method. If the supplied method is public and declared
in a public type, the supplied method will be returned. Otherwise, this
method recursively searches the class hierarchy and implemented
interfaces for an equivalent method that is public and declared in a
public type. If a publicly accessible equivalent method cannot be
found, the supplied method will be returned, indicating that no such
equivalent method exists.

All usage of getInterfaceMethodIfPossible() has been replaced with
getPubliclyAccessibleMethodIfPossible() in spring-beans and
spring-expression. In addition, getInterfaceMethodIfPossible() has been
marked as deprecated in favor of the new method.

As a bonus, the introduction of getPubliclyAccessibleMethodIfPossible()
allows us to delete a fair amount of obsolete code within the SpEL
infrastructure.

See gh-29857
Closes gh-33216
2024-08-22 14:35:21 +02:00
Sébastien Deleuze c71409821d Polishing
Closes gh-33402
2024-08-20 18:32:37 +02:00
dev-chpark a9cbb01a45 Rename test method to clarify its purpose
See gh-33402
2024-08-20 18:32:30 +02:00
Sam Brannen 04271c3ead Merge branch '6.1.x' 2024-08-18 13:04:21 +02:00
Sam Brannen 143736e59b Enforce order of Javadoc tags for records
Closes gh-33403
2024-08-18 13:01:43 +02:00
Juergen Hoeller e1cf203295 Merge branch '6.1.x'
# Conflicts:
#	framework-platform/framework-platform.gradle
2024-08-13 19:05:20 +02:00
Juergen Hoeller 8be5010f5d LocaleEditor supports BCP 47 language tags as well
Closes gh-33348
2024-08-13 18:50:30 +02:00
Sam Brannen 3863b77536 Merge branch '6.1.x' 2024-08-08 14:20:56 +03:00
Sam Brannen bcffa15c7d Reinstate qualifier support for JSR-330 @⁠javax.inject.Named
This commit revises QualifierAnnotationAutowireCandidateResolver to
reinstate "qualifier" support for the legacy JSR-330
@⁠javax.inject.Named annotation.

See gh-31090
Closes gh-33345
2024-08-08 14:20:06 +03:00
Sam Brannen f9d2641fd5 Update field name to reflect switch to Jakarta 2024-08-08 13:22:00 +03:00
Sam Brannen 3b506e11a1 Polishing 2024-08-08 13:22:00 +03:00
Stéphane Nicoll 0a2611b22f Harmonize NoUniqueBeanDefinitionException message
This commit makes sure that the programmatic exception that is thrown
by the cache abstraction uses the same message structure as a default
message produced by NoUniqueBeanDefinitionException.

Closes gh-33305
2024-08-02 16:24:43 +02:00
Stéphane Nicoll f63fc01d22 Merge branch '6.1.x' 2024-07-31 16:56:22 +02:00
Stéphane Nicoll 850a0de1b0 Suppress deprecated warnings for autowiring
This commit extends our handling of deprecated with AOT to autowiring.

Closes gh-33295
2024-07-31 16:51:06 +02:00
Stéphane Nicoll fc28926c15 Merge branch '6.1.x' 2024-07-25 16:29:07 +02:00
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