mirror of
https://github.com/eclipse-aspectj/aspectj.git
synced 2024-09-03 05:54:57 +02:00
31 lines
682 B
Plaintext
31 lines
682 B
Plaintext
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
|
|
|
import java.lang.annotation.*;
|
|
|
|
@Retention(RUNTIME)
|
|
@Inherited
|
|
@interface MyAnnotation {}
|
|
|
|
public aspect A perthis(annotatedClasses()) {
|
|
|
|
pointcut annotatedClasses() : @this(MyAnnotation);
|
|
|
|
before(): initialization(*.new(..)) {System.err.println(thisJoinPoint.getSignature().getDeclaringType()); }
|
|
|
|
public static void main(String []argv) {
|
|
new Foo();
|
|
new Goo();
|
|
new Boo();
|
|
new Soo();
|
|
}
|
|
}
|
|
|
|
// yes/no indicates if runtime match expected for staticinitialization
|
|
|
|
@MyAnnotation class Foo { } // YES
|
|
|
|
class Goo { } // NO
|
|
|
|
@MyAnnotation class Boo { } // YES
|
|
|
|
class Soo extends Boo { } // YES |