Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Matching unwanted calls to toString()

> I think the "args" pointcut expression is a binding device for the
> arguments of an advised method, not a filtering device -- correct me
> if I'm wrong, folks.

Not quite right, it can be used as a filtering device but it filters
on the runtime type information and not the compile time type
information.  Due to it involving runtime type information, it cannot
be used with declare warning/error.

Andy

On 22 March 2010 02:41, Roland Illig <rillig@xxxxxxxxxxxx> wrote:
> Hi,
>
> in a current project, I want to find all calls to toString() methods which may generate unwanted text like "ClassName@1234567". For that, I have written the following AspectJ-like code:
>
>  declare warning:
>    call(* StringBuilder.append(Object))
>    && !args(Exception)
>    && !args(Integer)
>    && !args(Double):
>      "Hidden toString()";
>
> What I wanted to express is:
>
>  * if the append(Object) method is called, give me a warning.
>  * but don't do so if the compile-time type of the argument
>    is an instanceof Exception, Integer or Double.
>
> Now the AspectJ compiler tells me I cannot use "args" in a declare statement. Why can't I?
>
> Roland
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


Back to the top