Allow @Aspect
classes to extend concrete @Aspect
classes
#29830
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Overview
AbstractAspectJAdvisorFactory#validate()
currently throws anAopConfigException
if the superclass of a concrete@Aspect
class is notabstract
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
The text was updated successfully, but these errors were encountered: