Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Different resolution scope for Named and Anonymous pointcut annotations?

Looks like a bug to me. Can you raise at: https://bugs.eclipse.org/bugs/enter_bug.cgi?product=AspectJ - it should be consistent. However, from the docs:

"Using the code style, types referenced in pointcut expressions are resolved with respect to the imported types in the compilation unit. When using the annotation style, types referenced in pointcut expressions are resolved in the absence of any imports and so have to be fully qualified if they are not by default visible to the declaring type (outside of the declaring package and java.lang ). This does not apply to type patterns with wildcards, which are always resolved in a global scope."

So if Account is in a package you should always be qualifying it in annotation style - you seem to be getting away with not doing that. The import information is not stored in the class file and so the weaver can't see what it was when unpicking the strings.

Andy


On 12 February 2013 01:00, ccol002 <chriscol002@xxxxxxxxx> wrote:
I am using AspectJ annotations and for some reason it seems that the
resolution scope of pointcuts differs for a named pointcut versus an
anonymous pointcut.

For example in the code below an identical pointcut is resolved if anonymous
but not when it is named. The named pointcut will however match if I use a
wildcard instead of a specific type or if the aspect is moved to the same
package as the Account class.

Any thoughts?


import ... .Account;

@Aspect
public class MyClass {


//this does not match... but matches if Account is replaced by *
@Pointcut("execution(* Account.withdraw(..)) && args(amount)")
public void withdr(double amount){}

@Before("withdr(amount)")
public void dosomething1(double amount){}


//this matches
@Before("execution(* Account.withdraw(..)) && args(amount)")
public void dosomthing2(double amount){}

}



--
View this message in context: http://aspectj.2085585.n4.nabble.com/Different-resolution-scope-for-Named-and-Anonymous-pointcut-annotations-tp4650774.html
Sent from the AspectJ - users mailing list archive at Nabble.com.
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top