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

  • https://github.com/micrometer-metrics/micrometer/issues/3575