Thx Any I really appreciated your help.

You where correct in your assumption:


"

If you want to match calls *to* deprecated methods it would be more like:

call(public * *(..)) && @annotation(Deprecated)
"


This is what I want to accomplish.


This is the structure of my maven project:


myapp

  tests

  nodes


In 'nodes' module I have a package called aspects where I have the aspect 
DeprecatedMethodLogger.aj

that I will 'weave' into the classes of nodes module.

Under tests I have Demo class to trigger deprecated method call, getBoards(), 
that is in nodes. This is for testing purposes.

Later on there will be calls not in myapp, but outside, that will make calls to 
deprecated methods in nodes module.


Demo.java


public class Demo extends Test{

    @Test
    public void test() {
      Node node = new Node();
      Handler handler = node.getObjectHandler();
      //getBoards() is the deprecated method.
      Boards boards = handler.getBoards();


    }
}



DeprecatedMethodLogger.aj


pointcut deprecatedMethods() : call(public * *(..)) && @annotation(Deprecated);


before() : deprecatedMethods() {
       log("[Deprecated Method Usage]" 
+thisEnclosingJoinPointStaticPart.getSignature().getDeclaringTypeName()+" --> 
"+"\n");
    }


This will print the 'Handler' class that calls the method getBoards() which is 
deprecated. I want:


Caller:  Demo.test()

Called: Handler.getBoards()


What am I lacking?


br,


//mikael







________________________________
Från: aspectj-users-boun...@eclipse.org <aspectj-users-boun...@eclipse.org> för 
Mikael Petterson <mikaelpetter...@hotmail.com>
Skickat: den 21 september 2017 11:35
Till: Frank Pavageau; aspectj-users@eclipse.org
Ämne: Re: [aspectj-users] How to get the enclosing class in a Pointcut


Thx!


I got your reply but why did I not get his? Do I need to make any changes to 
get them?


br,


//mike







________________________________
Från: Frank Pavageau <frank.pavag...@gmail.com>
Skickat: den 21 september 2017 07:54
Till: aspectj-users@eclipse.org; Mikael Petterson
Ämne: Re: [aspectj-users] How to get the enclosing class in a Pointcut

2017-09-21 9:46 GMT+02:00 Mikael Petterson 
<mikaelpetter...@hotmail.com<mailto:mikaelpetter...@hotmail.com>>:

So no input on this one?

Yes, Andy answered on the list itself : 
https://dev.eclipse.org/mhonarc/lists/aspectj-users/msg15087.html

Regards,
Frank

_______________________________________________
aspectj-users mailing list
aspectj-users@eclipse.org
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to