Skip to content

Commit a7aaf31

Browse files
committed
Updated CGLIB AOP proxy note on constructor invocations
Issue: SPR-13103
1 parent 0b2c3da commit a7aaf31

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/asciidoc/core-aop.adoc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,13 +2432,10 @@ so. However, there are some issues to consider:
24322432
CGLIB classes are repackaged under org.springframework and included directly in the
24332433
spring-core JAR. This means that CGLIB-based proxy support 'just works' in the same
24342434
way that JDK dynamic proxies always have.
2435-
* The constructor of your proxied object will be called twice. This is a natural
2436-
consequence of the CGLIB proxy model whereby a subclass is generated for each proxied
2437-
object. For each proxied instance, two objects are created: the actual proxied object
2438-
and an instance of the subclass that implements the advice. This behavior is not
2439-
exhibited when using JDK proxies. Usually, calling the constructor of the proxied type
2440-
twice, is not an issue, as there are usually only assignments taking place and no real
2441-
logic is implemented in the constructor.
2435+
* As of Spring 4.0, the constructor of your proxied object will NOT be called twice
2436+
anymore since the CGLIB proxy instance will be created via Objenesis. Only if your
2437+
JVM does not allow for constructor bypassing, you might see double invocations and
2438+
corresponding debug log entries from Spring's AOP support.
24422439

24432440
To force the use of CGLIB proxies set the value of the `proxy-target-class` attribute of
24442441
the `<aop:config>` element to true:

0 commit comments

Comments
 (0)