Ensure Spring AOP generates JDK dynamic proxies for lambdas

Prior to this commit, if AOP proxy generation was configured with
proxyTargetClass=true (which is the default behavior in recent versions
of Spring Boot), beans implemented as lambda expressions or method
references could not be proxied with CGLIB on Java 16 or higher without
specifying `--add-opens java.base/java.lang=ALL-UNNAMED`.

This commit addresses this shortcoming by ensuring that beans
implemented as lambda expressions or method references are always
proxied using a JDK dynamic proxy even if proxyTargetClass=true.

Closes gh-27971
This commit is contained in:
Sam Brannen
2022-02-04 19:41:46 +01:00
parent 6bc7d41734
commit 5d7a632965
5 changed files with 131 additions and 6 deletions

View File

@@ -51,7 +51,7 @@
<!-- Type Names -->
<module name="TypeName">
<property name="format" value="^[A-Z][a-zA-Z0-9_]*(?&lt;!Test)$" />
<property name="format" value="^[A-Z][a-zA-Z0-9_$]*(?&lt;!Test)$" />
<property name="tokens" value="CLASS_DEF" />
<message key="name.invalidPattern"
value="Class name ''{0}'' must not end with ''Test'' (checked pattern ''{1}'')." />