Consider a class C, the pointcut target(org.xyz.SomeInterface), and the execution join point for some method in C.
When AspectJ evaluates whether or not the pointcut can match such a join point, it says "maybe". The reason is that someone may later introduce a new type
class D extends C implements SomeInterface { ... }
and if the method declared in C executes for an instance of D, then the join point should be matched.
However... in Spring, we know the exact type of the bean, and there is no chance that a subtype will be introduced later on. Therefore, we should optimize matching in this case, so that we don't create proxies that will never actually have any work to do at runtime.
The one caveat to this is the declare parents construct, which can introduce additional interfaces to a bean. We need to ensure that this() and target() pcds still continue to match on interfaces that are introduced via a declare parents construct.
Fix committed to head. I had to add an "IntroductionAwareMethodMatcher" to take into account declare parents constructs. The solution is somewhat ugly because it needs some information not available in the public AspectJ tools API. AspectJ enhancement request 151593 has been raised to cover this, and the Spring solution can be improved once AspectJ provides the needed public API.
Mike Youngstrom opened SPR-2168 and commented
I have an aspect with a pointcut:
@Around
("@target
(org.lds.stack.spring.serviceproxy.ServiceProxy)")I'm using aop:aspectj-autoproxy/ and a bean with the target class org.springframework.orm.jpa.JpaTemplate is getting proxied.
If I remove the pointcut then my JpaTemplate not longer gets proxied.
Mike
Affects: 2.0 M5
Issue Links:
@target
PointCut causes unrelated beans to be proxiedThe text was updated successfully, but these errors were encountered: