[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] thisJoinPoint.getSignature().getMethod() returns NULL in a call join point
|
Hi
I have the following strange behavior, where Im not sure, if its a bug or if its a mistake on my side. I just prepared a small test case to show it
I have 2 interfaces, the first, the top defines mayPerform
public interface Authorization {
boolean mayPerform(String user, String action);
}
The second extends the first and adds
public interface AuthorizationAdmin extends Authorization {
boolean mayPerform2(String user, String action);
}
Then there is an implementation of these 2 methods doing nothing spectacular:
public class AuthorizationImpl implements AuthorizationAdmin {
/* ========== interface Authorization ============*/
public boolean mayPerform(String user, String action) {
System.out.println("executing mayPerform()");
return true;
}
/* ========== interface AuthorizationAdmin ============*/
public boolean mayPerform2(String user, String action) {
System.out.println("executing mayPerform2()");
return true;
}
}
Here is the aspect, which returns NULL when calling the method mayPerform(..) on the Authorization Interface but when I call mayPerform2(..) it works fine.
public aspect CallAndMethodSignatureAspect {
pointcut callAnyPublicMethodInAuthorization() : call(public * Authorization+.*(..) );
Object around() : callAnyPublicMethodInAuthorization() {
MethodSignature methodSignature = (MethodSignature) thisJoinPoint.getSignature();
// returns NULL when calling a method defined in the top interface "Authorization"
Method method = methodSignature.getMethod();
System.out.println(method);
System.out.println(methodSignature.toLongString());
return proceed();
}
}
Here is the unit test
import junit.framework.TestCase;
public class CallTest extends TestCase {
private AuthorizationAdmin admin;
public void testMayPerform() {
admin = new AuthorizationImpl();
boolean bool = admin.mayPerform("peter", "query");
assertTrue(bool);
}
public void testMayPerform2() {
admin = new AuthorizationImpl();
boolean bool = admin.mayPerform2("peter2", "query2");
assertTrue(bool);
}
}
Why is that ? If I switch to execution instead of call then it works as expected. I can also provide the test project, if required.
Im using AspectJ 1.5.2.
Thanks
Guido