Skip to main content

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

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


Back to the top