带有注释的类的子类的@AspectJ切入点

我正在寻找一个切入点,该切入点匹配将类与特定注释子类化的类中的方法执行。 优秀的AspectJ备忘单帮我创建了以下切入点:

within(@my.own.annotations.AnnotationToMatch *) && execution(* *(..)) 

这匹配带有@AnnotationToMatch的类A的所有方法调用,但不匹配扩展A的类B的方法。如何匹配两者?

 public aspect AnnotatedParentPointcutAspect { //introducing empty marker interface declare parents : (@MyAnnotation *) implements TrackedParentMarker; public pointcut p1() : execution(* TrackedParentMarker+.*(..)); before(): p1(){ System.out.println("Crosscutted method: " +thisJoinPointStaticPart.getSignature().getDeclaringTypeName() +"." +thisJoinPointStaticPart.getSignature().getName()); } } 

另一种更简单的可能性是将注释声明为@Inherited – 因此它也适用于子类。