[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Java 8 type annotations
|
There is no AspectJ support for matching on type annotations right now.
You could use a declare @type and then match on annotations:
aspect X {
// If a member has @Anno, stick @Anno on the type
declare @type: hasmethod(@Anno * *(..)): @Anno;
// If the type has @anno, advise static initialization
before(): @within(Anno) && staticinitialization(*) {
System.out.println("Advising "+thisJoinPointStaticPart);
}
}
This will work in this kind of setup:
new Runnable() {
@Anno public void run() {
System.out.println("xyz");
}
}.run();
You will need to compile with -XhasMember to allow use of the hasmethod() pointcut.
cheers,
Andy
> On Jan 2, 2018, at 12:06 PM, Fabian Bergmark <fabian.bergmark@xxxxxxxxx> wrote:
>
> Is it possible to capture initialization of a class with specific type
> annotation, like
>
> new @Link Runnable() { .. }
>
> If not, would it be possible to capture initialization of a class
> which contains a method with a specific annotation?
>
> Cheers
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/aspectj-users