Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Can we access any static join point information in declare error/warning?

Declare warning and error are matched during compilation.  This means
it would be a little awkward to run any code being compiled as part of
producing the message.  However, with appropriate definition of
inserts, we are basically talking about the same feature:

%DT% - declaring type name
%N% - name

declare warning: call(* Hello.*(..)): "Illegal call to %DT%.%N%(..)";


Andy

On 3 March 2010 09:34, Sebastien Tardif <stardif@xxxxxxxxxxxx> wrote:
> This bug exist: https://bugs.eclipse.org/bugs/show_bug.cgi?id=48080
>
> The following syntax is obviously very natural and I was surprise it doesn't work:
>
>  declare warning: call(* Hello.*(..)) {
>        Signature sig = thisJoinPointStaticPart.getSignature();
>        return "Illegal call to " + sig.getDeclaringType().getName() +
>            "." + sig.getName() + "(..)";
>    }
>
>
> ________________________________
>
> From: aspectj-users-bounces@xxxxxxxxxxx on behalf of Andy Clement
> Sent: Wed 3/3/2010 12:17 PM
> To: aspectj-users@xxxxxxxxxxx
> Subject: Re: [aspectj-users] Can we access any static join point information in declare error/warning?
>
>
>
> I thought we already had an enhancement request open for that, but I
> couldn't find it.  Feel free to raise it.  But just to check we both
> mean the same thing, in my mind this feature means the static join
> point information can be inserted into the message string:
>
> declare warning: execution(@Foo *(..)): "Method %M is annotated Foo!!";
>
> Is that what you mean too?
>
> You can get some way along by registering your own message handler
> with AspectJ and processing declare errors/warnings in it.  It at
> least gives you the source location to do some extra processing and
> possibly augment the text, but I can't quite recall it if gives you
> the joinpoint too.
>
> Andy
>
> On 2 March 2010 19:05, Sebastien Tardif <stardif@xxxxxxxxxxxx> wrote:
>> Can we access any static join point information in declare error/warning message?
>>
>> Looks like that should be easy to support.
>>
>> I want to use this feature to error out only on new policy violation, so first pass is to use warning to find all the violation, and I prefer getting a useful string so that it is easy to copy/paste to the declare error.
>>
>> End result will be that legacy policy violation will show warning, new policy violation will generate error.
>>
>>
>> _______________________________________________
>> aspectj-users mailing list
>> aspectj-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>
>>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>


Back to the top