[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [aspectj-users] Some comments about the documentations
|
Jonathan Amir says:
Hello,
I looked at the programming guide in the aspectJ documentations
online, and I have a couple of comments (I don't know if they
should be classified as errors or not):
Both bug reports and enhancement requests are welcome *smile*
1) In appendix B, heading "Pointcuts", sub-heading "Primitive
pointcuts", there is the following example:
aspect GuardedX {
static final int MAX_CHANGE = 100;
before(int newval): set(int T.x) && args(newval) {
if (Math.abs(newval - T.x) > MAX_CHANGE)
throw new RuntimeException();
}
}
I believe that this example is misleading, because it requires the
field x of class T to be declared as a static field. Using ajdt, I
tried to run this example (by creating a simple class T with field
x) but it didn't work. Making the field static solved the problem.
I think that the confusing arises because in the first occurrence
of T.x (in the point-cut portion of the advice declaration) it
doesn't matter whether x is static or not. However, in the second
occurrence it does matter.
Good point. I've changed the set pointcut to "set(static int T.x)"
2) In section 1, heading "Development Aspects", sub heading
"Contract Enforement", there is an example that declares a
static aspect. To the best of my knowledge, the keyword
"static", when used before an aspect declaration, declares the
aspect to be a subclass of another class (similarly to the
static class declarations in Java).
Declares it to be a static inner class, not a subclass, but yes, it is
intended to be just like Java
However, the problem that I want to point out is that this is
not mentioned anyway in the documentations (or at least I
couldn't find it), and this issue puzzled me for a while.
I've added an anhancement request in bugzilla for this to be better
explained.
Thanks for your input,
-erik