[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Matching based on extension type

not statically, but dynamically:

    before(): staticinitialization(*Base) {
        if (thisJoinPointStaticPart.getSignature().getDeclaringType().getSuperclass().getName().endsWith("Base")) {
            throw new IllegalStateException(thisJoinPointStaticPart.getSignature().getDeclaringType().getName()+" extends "+thisJoinPointStaticPart.getSignature().getDeclaringType().getSuperclass().getName());
        }
    }

Andy


2009/8/14 Paulo Zenida <paulo.zenida@xxxxxxxx>
Hello all.

Is it possible to do AspectJ matching based on the extension clause defined in a given type? For instance, can I define a policy in which it is not possible for a class whose name ends with Base extend another class whose name also ends with Base?

Something like (simplified syntax):

declare warning : *Base extends *Base : "You should not extend a Base class from another Base class";

I looked for it in the Web and tried several approaches but no good results, unfortunately... :-(

Thank you for your attention.

Kind regards,

Paulo Zenida

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users