Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Inconsistent behavior for declare @method / declare @field?

Hi,

I have a class X that has two associations to Y class as follow :

public class X {

private Y y1;
private Y y2;

public Y getY1() {
return y1;
}

public void setY1(Y y) {
this.y1 = y;
}

public Y getY2() {
return y2;
}

public void setY2(Y y) {
this.y2 = y;
}
}

Nothing special for class Y.

I have an aspect like this which is OK, but  access() point cut does not capture anything. Fine.

public aspect OneToOneAspect {

pointcut access() : execution(Y X.a*());
after() : access() {
System.out.println("Access");
}
}

But, if I add similar method signature like Y X.a*() but for declare @method, I had compilation error:
[error] The method 'public com.arizal.business.Y com.arizal.business.X.a*()' does not exist

The aspect after declare addition is the following:
public aspect OneToOneAspect {

declare @method : public Y X.a*(): @OneToOneAccessor;
pointcut access() : execution(Y X.a*());
after() : access() {
System.out.println("Access");
}
}

Why the pointcut definition does not throw error while the declare method does ?  Is it expected ?

I would prefer to have compilation error in both cases. Is it possible ?

Cheers,
Anwar .



Back to the top