[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Valid pointcut no more valid in aspectj 1.2.1 rc1 ?

The messages from Andy & I crossed in the post... of course, if someone 
else wants to look at this as Andy suggests, I'd be more than happy!

-- Adrian
Adrian_Colyer@xxxxxxxxxx



Adrian Colyer/UK/IBM@IBMGB 
Sent by: aspectj-users-admin@xxxxxxxxxxx
18/11/2004 08:45
Please respond to
aspectj-users@xxxxxxxxxxx


To
aspectj-users@xxxxxxxxxxx
cc

Subject
Re: [aspectj-users] Valid pointcut no more valid in aspectj 1.2.1 rc1 ?






There have been enough user cases of the 'single binding' restriction that 

we will consider relaxing this rule for pointcuts where there would be no 
ambiguity in the binding. I might take a look into this on my flight to 
Vancouver today...

-- Adrian
Adrian_Colyer@xxxxxxxxxx



Simon Denier <Simon.Denier@xxxxxx> 
Sent by: aspectj-users-admin@xxxxxxxxxxx
15/11/2004 13:33
Please respond to
aspectj-users@xxxxxxxxxxx


To
aspectj-users@xxxxxxxxxxx
cc

Subject
[aspectj-users] Valid pointcut no more valid in aspectj 1.2.1 rc1 ?






Hi, and excuse me for responding so late upon the upcoming release. (I 
used to post this message on aspect-dev list, but it seems some messy 
email translation got it moderated.)

I am in trouble because aspectj 1.2.1 rc1 declares as an error a
composition of pointcuts which used to work in a previous release (1.2).
To sum up, it deals with the composition of multiple this() operator
when reusing some pointcut.

I write a simple test case :

public class This {
    public void foo(){        System.out.println("This.foo()");    }
    public void bar(){        System.out.println("This.bar()");    }
    public static void main(String[] args) {        new This().foo();    }
}

aspect GetThis {
    pointcut foo1(This t): execution( void This.foo() ) && this(t);
    pointcut fooBar(This t): foo1(t) || (execution( void This.bar() ) &&
this(t));
    before(This t): foo1(t){   System.out.println("foo1 - Before
this.foo() " + t);    }
    before(This t):fooBar(t){System.out.println("fooBar -Before
This.foo() || This.bar() "+t);}
}

Error : "Cannot use this() to match at this location and bind a formal
to type 'This' - the formal is already bound to type 'This'.  The
secondary source location points to the problematic this()."


Since it used to work before,  I cant see the rationale behind this new
error. Am I missing something ?

PS : since this appears as an explicit feature and not as a side effect,
I could see this as a bug and did not submit a bug report.

***

Anyway, it reminds me of a similar error (this time both in 1.2 & 1.2.1)
about multiple args() : it is even more disturbing as you get an error
in 1.2 but the project does compile and run fine (not anymore in 1.2.1)
! So I get an error at compilation/weaving time but the aspectized
program works as expected.

The question is the same : what for ? What is the problem/danger in
using such a composition ? It is rather clumsy since I actually manage
to work around by duplicating the advice code, a process obviously bad.


Test case :

public class Args {
    void foo(int x){        System.out.println("Args.foo() " + x);    }
    void bar(int x){        System.out.println("Args.bar() " + x);    }
    public static void main(String[] args) {
        new Args().foo(1);
        new Args().bar(2);
    }
}

aspect GetArgs {
    pointcut fooA(int x): execution( void Args.foo(int) ) && args(x);
    pointcut barA(int x): execution( void Args.bar(int) ) && args(x);
    pointcut Args(int x): fooA(x) || barA(x);
    before(int x): Args(x){        System.out.println("before execution
" + x);    }
}


Error : "Ambiguous binding of type int using args(..) at this line.  Use
one args(..) per matched join point, see secondary source location for
location of extraneous args(..)"


Feel free to comment or ask me further information (and excuse the long
mail and the perfectible english).

-- 
Simon

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users


_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users