Skip to content

Allow @Aspect classes to extend concrete @Aspect classes #29830

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
sbrannen opened this issue Jan 16, 2023 · 0 comments
Closed

Allow @Aspect classes to extend concrete @Aspect classes #29830

sbrannen opened this issue Jan 16, 2023 · 0 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@sbrannen
Copy link
Member

sbrannen commented Jan 16, 2023

Overview

AbstractAspectJAdvisorFactory#validate() currently throws an AopConfigException if the superclass of a concrete @Aspect class is not abstract and is also annotated with @Aspect.

This validation has been in place for a long time (likely as far back as Spring Framework 2.0) and was probably introduced to mimic the behavior of the AspectJ compiler which would discover all such @Aspect classes in the classpath and apply them, resulting in duplicate application of the behavior of the superclass.

In a Spring application, however, Spring's AOP support does not automatically scan the classpath for all @Aspect classes. Rather, a user must explicitly register an @Aspect class as a bean (or annotate it with a stereotype annotation such as @Component and have it picked up via component scanning). Thus, the onus lies on the user to avoid registration of an aspect and its superclass.

In light of the above, we should remove the corresponding validation from AbstractAspectJAdvisorFactory#validate() and allow @Aspect classes to extend concrete @Aspect classes.

Related Issues

@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement labels Jan 16, 2023
@sbrannen sbrannen added this to the 6.0.5 milestone Jan 16, 2023
@sbrannen sbrannen self-assigned this Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant