[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] thisJoinPoint.getSignature().getMethod() returns NULL in a call join point
|
I haven't verified it, but it looks like a bug to me. Would you submit it?
It would be interesting to update the test case to use an Authorization reference
for the call to mayPerform(..).
Thanks for the well-worded mail and test case.
Wes
> ------------Original Message------------
> From: "Guido Schmutz" <Guido.Schmutz@xxxxxxxxxxxx>
> To: aspectj-users@xxxxxxxxxxx
> Date: Thu, Aug-17-2006 3:11 PM
> Subject: [aspectj-users] thisJoinPoint.getSignature().getMethod() returns NULL in a call join point
>
> Hi
>
> I have the following strange behavior, where I’m not sure, if it’s a
> bug or if it’s 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.
>
> I’m using AspectJ 1.5.2.
>
> Thanks
> Guido
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>