Commit Graph

614 Commits

Author SHA1 Message Date
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
Juergen Hoeller a426f87a5f Merge branch '5.3.x'
# Conflicts:
#	build.gradle
#	spring-aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java
2022-07-13 17:08:21 +02:00
Juergen Hoeller 8e5c4903d4 Avoid synchronization in AbstractAspectJAdvice#calculateArgumentBindings
Aligned with the early calculateArgumentBindings call in ReflectiveAspectJAdvisorFactory.

Closes gh-26377
2022-07-13 16:47:35 +02:00
Sam Brannen 8242897c81 Merge branch '5.3.x' 2022-07-13 16:13:49 +02:00
Sam Brannen 2e4d7e4ef9 Polishing 2022-07-13 16:13:09 +02:00
Marc Wrobel c6be3b33c9 Fix and improve Javadoc in spring-aop
Closes gh-28803
2022-07-13 16:13:02 +02:00
Sam Brannen 49dfcad447 Remove AopProxyUtils.completeJdkProxyInterfaces(String...)
Since gh-28781 is still open for team discussion, this commit removes
the `String...` variant for AopProxyUtils.completeJdkProxyInterfaces.

Depending on the outcome of gh-28781, this method may be reintroduced
in 6.0 M6.

Closes gh-28745
2022-07-11 17:48:38 +02:00
Sam Brannen 7bfcb4c753 Reject sealed interfaces in AopProxyUtils.completeJdkProxyInterfaces()
See gh-28745
2022-07-11 17:47:41 +02:00
Sam Brannen 5178e9c28e Simplify hint registration for Spring AOP proxies
Prior to this commit, when users wished to register proxy hints for a
Spring AOP JDK dynamic proxy, they were required to explicitly specify
SpringProxy, Advised, and DecoratingProxy along with user interfaces.

This commit simplifies hint registration for Spring AOP proxies by
introducing two completeJdkProxyInterfaces() methods in AopProxyUtils,
one that accepts strings and one that accepts classes that represent
the user-specified interfaces implemented the user component to be
proxied. The SpringProxy, Advised, and DecoratingProxy interfaces are
appended to the user-specified interfaces and returned as the complete
set of interfaces that the proxy will implement.

Closes gh-28745
2022-07-10 20:10:12 +02:00
Sam Brannen 2a0b3c1af9 Polish AopProxyUtilsTests 2022-07-10 20:10:12 +02:00
Sam Brannen 2af08cf163 Merge branch '5.3.x'
# Conflicts:
#	spring-core/src/test/java/org/springframework/core/annotation/TypeMappedAnnotationTests.java
#	spring-test/src/test/java/org/springframework/test/context/junit4/TimedSpringRunnerTests.java
#	spring-test/src/test/java/org/springframework/test/util/MetaAnnotationUtilsTests.java
#	spring-test/src/test/java/org/springframework/test/util/OverriddenMetaAnnotationAttributesTests.java
2022-07-09 16:24:04 +02:00
Sam Brannen d274e893a6 Remove superfluous static declaration for enum, annotation, & interface 2022-07-09 16:16:13 +02:00
Sébastien Deleuze 1458d5f39f Add support for @Transactional in native images
This commit introduces a TransactionBeanRegistrationAotProcessor
in charge of creating the required proxy and reflection hints
when @Transactional is detected on beans.

It also refines DefaultAopProxyFactory to throw an exception
when a subclass-based proxy is created in native images
since that's unsupported for now (see gh-28115 related issue).

Closes gh-28717
2022-07-08 16:47:35 +02:00
Sébastien Deleuze 8ccf05adee Remove SpringProxyRuntimeHintsRegistrar
A dynamic mechanism to register proxy and reflection
hints for classes annotated by @Transactional is needed
instead.

See gh-28717
2022-07-07 18:10:53 +02:00
Sébastien Deleuze 0387d54607 Add support for Transactional in native-image
This commit annotates @Transactional with @Reflective
and registers proxy hints for SpringProxy.

Injection of proxied beans via their interfaces still fails
in native images with a
"No qualifying bean of type MyInterface" error.

See gh-28717
2022-07-07 10:30:34 +02:00
Sam Brannen 36cf1ac1ef Apply "instanceof pattern matching" in AopProxyUtils 2022-07-05 14:55:58 +02:00
Stephane Nicoll 6199835d6e Harmonize generated class name conventions
This commit moves the responsibility of naming classes to the
GenerationContext. This was already largely the case before, except that
the concept of a "mainTarget" and "featureNamePrefix" was specific
to bean factory initialization contributors.

ClassNameGenerator should now be instantiated with a default target
and an optional feature name prefix. As a result, it does no longer
generate class names in the "__" package.

GeneratedClasses can now provide a new, unique, GeneratedClass or
offer a container for retrieving the same GeneratedClass based on an
identifier. This lets all contributors use this facility rather than
creating JavaFile manually. This also means that ClassNameGenerator
is no longer exposed.

Because the naming conventions are now part of the GenerationContext, it
is required to be able to retrieve a specialized version of it if a
code generation round needs to use different naming conventions. A new
withName method has been added to that effect.

Closes gh-28585
2022-06-23 16:05:23 +02:00
Stephane Nicoll 90759fb38f Relocate duplicated mock implementations to test fixtures
Closes gh-28659
2022-06-20 08:55:52 +02:00
Stephane Nicoll 92961d75f0 Polish tests 2022-06-07 12:03:50 +02:00
Stephane Nicoll 176ea5e9a7 Fix registration of ScopedProxyBeanRegistrationAotProcessor
Closes gh-28561
2022-06-03 14:28:08 +02:00
Phillip Webb 8d79ec0b67 Allow AOT contributions to customize code fragments.
Update the `BeanRegistrationAotContribution` interface to allow
it to customize `BeanRegistrationCodeFragments`. This change
allows us to drop the `BeanRegistrationCodeFragmentsCustomizer`
interface since an `BeanRegistrationAotProcessor` can now be
used instead.

Closes gh-28557
2022-06-02 18:07:47 -07:00
Sam Brannen ee209de9cf Merge branch '5.3.x'
# Conflicts:
#	spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java
#	spring-context/src/test/java/org/springframework/ejb/access/LocalSlsbInvokerInterceptorTests.java
#	spring-context/src/test/java/org/springframework/ejb/access/SimpleRemoteSlsbInvokerInterceptorTests.java
#	spring-web/src/test/java/org/springframework/remoting/jaxws/JaxWsSupportTests.java
#	spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewResolutionIntegrationTests.java
2022-05-31 14:15:36 +02:00
Sam Brannen 1beb7068f6 Use new AssertJ exception assertions 2022-05-31 14:08:28 +02:00
Stephane Nicoll 6bd25f60dd Polish 2022-05-24 11:57:14 +02:00
Sam Brannen 70415b1781 Merge branch '5.3.x' 2022-05-17 15:41:08 +02:00
Sam Brannen 59c7bb1f86 Use Arrays.toString instead of Arrays.asList when generating Strings 2022-05-17 15:36:31 +02:00
Sam Brannen eb50a6f4a0 Further polishing regarding JDK baseline upgrade
See gh-28440
2022-05-10 17:01:40 +02:00
lihan a892ce80c1 Polishing regarding JDK baseline upgrade
Closes gh-28440
2022-05-10 17:01:40 +02:00
Phillip Webb 16e7f1f212 Complete refactor of AOT concepts
Remove the AOT code that now has an alternative API.

Closes gh-28414
2022-05-05 13:34:52 -07:00
Phillip Webb 588d4d8776 Update scoped proxy AOT support
Add `ScopedProxyBeanRegistrationCodeGeneratorFactory` to supply custom
scoped proxy bean registration code.

See gh-28414
2022-05-05 13:25:37 -07:00
Juergen Hoeller 17c778e3a0 Preserve javax nullability annotations for AOP Alliance fork
See gh-28410
2022-05-05 17:26:17 +02:00
Phillip Webb 63b129a3f7 Check that nullable annotations are from org.springframework.lang
Fix a few incorrect nullable annotation imports and add a checkstyle
rule to ensure they don't return.

Closes gh-28410
2022-05-03 11:14:53 -07:00
Stephane Nicoll 5378572b00 Clarify lambda code block methods 2022-04-26 15:13:43 +02:00
Stephane Nicoll f64fc4baff Generate appropriate bean registration code for scoped proxies
Closes gh-28383
2022-04-26 15:03:54 +02:00
Sam Brannen c9e7816762 Merge branch '5.3.x' 2022-04-09 10:43:02 +02:00
Sam Brannen 6fad00ed22 Ensure dynamic proxy with AOP introduction includes lambda interfaces
Closes gh-28209
2022-04-09 09:57:43 +02:00
Sam Brannen 5f6d8df34b Introduce isLambdaClass() as a public utility in ClassUtils
This commit extracts isLambda() from AopProxyUtils and makes it
publicly available as ClassUtils.isLambdaClass().

This is a prerequisite for gh-28209.
2022-04-09 09:57:43 +02:00
Juergen Hoeller 7e1782ea22 Merge branch '5.3.x'
# Conflicts:
#	build.gradle
#	spring-core/src/main/java/org/springframework/core/convert/Property.java
2022-04-08 13:10:34 +02:00
Juergen Hoeller 7aed6279a2 Consistent fallback in case of fast-class generation failure
Closes gh-28138
2022-04-08 13:02:36 +02:00
Sam Brannen b570f60560 Merge branch '5.3.x'
# Conflicts:
#	spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java
#	spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationClassFilter.java
#	spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMatchingPointcut.java
#	spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMethodMatcher.java
#	spring-beans/src/main/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessor.java
#	spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java
#	spring-context/src/main/java/org/springframework/jmx/export/annotation/ManagedNotification.java
#	spring-context/src/main/java/org/springframework/jmx/export/annotation/ManagedOperationParameter.java
#	spring-core/src/main/java/org/springframework/javapoet/support/package-info.java
#	spring-core/src/main/java/org/springframework/util/TypeUtils.java
#	spring-web/src/main/java/org/springframework/http/HttpMethod.java
2022-03-18 16:47:12 +01:00
Sam Brannen 64b64d9ba0 Stop referring to features as "Java 5" features
With a Java 8 baseline in place for quite some time now, it no longer
makes sense to refer to features such as annotations as "Java 5
annotations".

This commit also removes old `Tiger*Tests` classes, thereby avoiding
duplicate execution of various tests.
2022-03-18 16:32:30 +01:00
Sam Brannen be8224a590 Polish contribution
See gh-27818
2022-02-19 16:04:55 +01:00
Guirong Hu 01214b3473 Allow @Async qualifier to be declared with a placeholder or SpEL expression
Closes gh-27818
2022-02-19 15:09:40 +01:00
Sam Brannen 6a73d2655f Polishing 2022-02-19 14:59:54 +01:00
Sam Brannen 8c6d59aaaf Polish contribution
See gh-28014
2022-02-19 14:43:26 +01:00
a.yazychyan c5c926726d Use enhanced switch expressions where feasible
Closes gh-28014
2022-02-19 14:34:05 +01:00
Juergen Hoeller 69db0f7b45 Merge branch '5.3.x'
# Conflicts:
#	build.gradle
2022-02-16 20:07:55 +01:00
Juergen Hoeller f8a59c267f Polishing 2022-02-16 20:04:51 +01:00
Stephane Nicoll 9a0f691e86 Merge branch '5.3.x' 2022-02-05 13:59:45 +01:00
izeye 4ab03fede8 Fix Javadoc since for AopProxyUtils.isLambda()
See gh-28010
2022-02-05 13:59:01 +01:00