Skip to content

Enhance aspect to support superclass aspects #34667

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

JoshuaChen
Copy link
Contributor

Summary:

  1. Continue to fix the missing logic of parameter binding in PR Stop assuming that AspectJ Advice has JoinPoint as the first argument #34316
  2. AspectJ correctly identifies the subclasses of abstract classes, fixing the failure of pointcut binding
  3. Change the JointPoint in AbstractTransactionAspect.aj to ProceedingJoinPoint to fix the problem of parameter binding failure when calling @transaction at runtime

For more background, see PR #34316 and #34656

After this PR, the following exceptions have been fixed

2025-03-26T16:24:33.336+08:00 DEBUG 17613 --- [           main] o.s.a.aspectj.AspectJExpressionPointcut  : Pointcut parser rejected expression [transactionalMethodExecution(txObject)]: java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting 'identifier' at character position 0

Signed-off-by: Joshua Chen <27291761@qq.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 28, 2025
@JoshuaChen JoshuaChen changed the base branch from main to 6.2.x March 28, 2025 08:54
@jhoeller
Copy link
Contributor

While this is definitely possible, I'm afraid we do not intend to go there. @EnableAspectJAutoProxy is only meant to deal with common @Aspect beans where such named pointcut indirection via inheritance is not a problem to deal with. Our management of different aspect types and different AspectJ usage scenarios is complex enough already.

Last but not least, we actually mean to ignore those weaving-only aspects for proxying purposes; that's by design. If @EnableTransactionManagement(mode=ASPECTJ) and @EnableAspectJAutoProxy are both declared, the former uses the transaction aspect for weaving purposes whereas the latter just looks at all custom @Aspect beans for proxying purposes. This is what the common intention is in existing applications, so we need to keep them separate.

So to be clear, we actually do not want our transaction aspect (or our similarly designed caching aspect) to be picked up by @EnableAspectJAutoProxy in such a setup since this would cause double invocation of the functionality around the same method: once from weaving and once from proxying. That's what our total exclusion of ajc-compiled aspects was for, and while this has been relaxed in the meantime, we still need to keep the weaving scenarios separate in common application setups.

So thanks for your efforts but please note that we do not intend to accept further revisions in this area.

@jhoeller jhoeller closed this Mar 28, 2025
@jhoeller jhoeller added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants