[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] feature suggestion for comment: error messages for declare.error/warning

In many cases, when I have written declare error or declare warning, I'd like to be able to craft a context-sensitive message. For example, consider:

declare error: set(private * *.*) && !inSetterOrConstructor():
    "don't set privates directly, use a setter";

If we had access to thisJoinPointStaticPart and a printf-style/message format-style language this could be improved to be:

declare error: set(private * *.*) && !inSetterOrConstructor():
    "don't set {0}{1}.{2} directly, use a setter",

This implicitly uses thisJoinPointStaticPart as the scope for evaluating the message text; I am guessing that this is fairly reasonable to implement, whereas doing anything more is a lot of work.

I'd be interested in feedback from other users. Would you find this useful? Are there other elements of this you'd like to see? I'm also interested in comments from the committers on how hard it would be to implement this (and how to design it to make it feel natural yet make implementation tractable).

This idea first came up in discussion with an AspectJ user at a tutorial I was giving; thank you for suggesting it.


p.s. Here's an example of something that would be nice to do, but I believe would be a lot of work to implement:

declare error: set(private * *.*) && !inSetterOrConstructor():
    "don't set {0}.{1} directly, use {2}",

Ron Bodkin
Chief Technology Officer
New Aspects of Security
m: (415) 509-2895