Glen,
 
One way I can think of is to use declare warning [or declare error] to capture 
all those places where a deprecate class is used and have the compiler spit out 
a message when it finds its usage.  Maybe something like the following taken 
from the Quick Reference guide 
[http://www.eclipse.org/aspectj/doc/released/quick5.pdf]:
 
declare warning : call(Priority.new(..)) : "bad construction of Priority 
object.  Deprecated usage, please use Level" ;
 
Ron

________________________________

From: [EMAIL PROTECTED] on behalf of Glenn Farrow
Sent: Wed 9/20/2006 7:33 AM
To: [email protected]
Subject: Re: [aspectj-users] It was related to inheritance and 
deprecatedmethods ...


Ya as per my previous email I understand that it wasn't matching because the 
method signature for the log method specifies a Priority for the first 
parameter, even though that class is deprecated.  My point was that Aspectj 
should match based on the type of the parameter actually being passed (which is 
a Level).  The run time type of that parameter must be preserved in the byte 
code as a Level.

What if, for example to catch uses of a deprecated class, I wanted to 
differentiate between calls to log() that were passing in a Priority and calls 
that were passing in a Level?  I would have no way to do this if matching is 
based on the method signature and not the actual parameter types passed.


Matthew Webster wrote: 


        Glenn, 
        
        The first pointcut does not match because the call() PCD does not 
match. You have asked to match a method that takes Level as the first parameter 
while the method you are calling takes a Category. The match takes place at 
compile- not run-time. Your other pointcuts match with a run-time test because 
you are matching and binding with the args() PCD. They will also match the call 
below but the advice will not be invoked at run-time because the first argument 
is a Category and not a Level: 
        
                logger.log(Priority.FATAL,""); 
        
        The following pointcut will always match without a runtime test: 
        
                pointcut logCall() : target(Logger) && !within(LoggingAspect) 
&& call(void log(Priority, ..)); 
        
        
        
        Matthew Webster
        AOSD Project
        Java Technology Centre, MP146
        IBM Hursley Park, Winchester,  SO21 2JN, England
        Telephone: +44 196 2816139 (external) 246139 (internal) 
        Email: Matthew Webster/UK/IBM @ IBMGB, [EMAIL PROTECTED]
        http://w3.hursley.ibm.com/~websterm/ 
        
        
        
Glenn Farrow <[EMAIL PROTECTED]> <mailto:[EMAIL PROTECTED]>  
Sent by: [EMAIL PROTECTED] 

19/09/2006 16:50 
Please respond to
[EMAIL PROTECTED]; Please respond to
[email protected]


To
Matthew Webster/UK/[EMAIL PROTECTED]    
cc
[email protected]       
Subject
[aspectj-users] It was related to inheritance and deprecated        methods ... 


        
        




        although I believe it should still work with Level.
        
        Here is the log4j method declaration:
        
                       public void log(Priority p, Object message); 
        however Priority is deprecated so you are supposed to pass in a Level 
(which implements Priority).
        
        Here is my method call:
        
                        _logger.log(Level.ERROR, "My error message");
        
        The following pointcut does NOT match:
        
           pointcut logCall(Level p) : target(Logger) && args(p, ..) && 
!within(LoggingAspect) && call(void log(Level, ..));
        
        The following pointcuts DO match:   
        
           pointcut logCall(Level p) : target(Logger) && args(p, ..) && 
!within(LoggingAspect) && call(void log(..));
           pointcut logCall(Level p) : target(Logger) && args(p, ..) && 
!within(LoggingAspect) && call(void log(Priority p, ..));
           pointcut logCall(Level p) : target(Logger) && args(p, ..) && 
!within(LoggingAspect) && call(void log(Priority+ p, ..));
        
        So even though I am passing in a Level in my method call, the fact that 
the method is defined to accept a (deprecated) Priority prevents the first 
pointcut from matching?
        
        Also can anyone explain why the 3 pointcuts that do match all require a 
runtime test?
        
        Glenn
        
        
        Matthew Webster wrote: 
        
        Glenn, 
        
        Unfortunately pointcuts not matching is one of the hardest things to 
diagnose. Could you post you whole aspect (or as much of it as you are willing 
to disclose) and a full example of a join point you are trying to match. Also 
could you give some examples of your environment e.g. AJDT, Ant or load-time 
weaving. 
        
        Cheers 
        
        Matthew Webster
        AOSD Project
        Java Technology Centre, MP146
        IBM Hursley Park, Winchester,  SO21 2JN, England
        Telephone: +44 196 2816139 (external) 246139 (internal) 
        Email: Matthew Webster/UK/IBM @ IBMGB, [EMAIL PROTECTED] <mailto:[EMAIL 
PROTECTED]> 
        http://w3.hursley.ibm.com/~websterm/ 
<http://w3.hursley.ibm.com/%7Ewebsterm/%06quot;>  
        
        
Glenn Farrow <[EMAIL PROTECTED]> <mailto:[EMAIL PROTECTED]>  
Sent by: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>  

19/09/2006 15:43 

Please respond to
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> ; Please respond to
[email protected] <mailto:[email protected]> 



To
Ron Bodkin <[EMAIL PROTECTED]> <mailto:[EMAIL PROTECTED]>       
cc
[email protected] <mailto:[email protected]>    
Subject
Re: [aspectj-users] Pointcut fails to match when arguments        combinedwith 
".."     



        
        


        
        
        
        No, tried that too previously.  Same result.
        
        
        
        Ron Bodkin wrote:
        > I think you want args(p, ..) to match any number of arguments as long 
as the
        > first one is a Level; args(p) will match exactly one argument of type 
Level.
        >
        > -----Original Message-----
        > From: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> 
        > [mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> ] On Behalf Of 
Glenn Farrow
        > Sent: Tuesday, September 19, 2006 6:33 AM
        > To: [email protected] <mailto:[email protected]> 
        > Subject: [aspectj-users] Pointcut fails to match when arguments 
combinedwith
        > ".."
        >
        > Observer the following pointcut and advice which is supposed to match
        > all calls to Logger.log(..).  Logger.log always takes a Level as the
        > first parameter.  However the advice never gets applied.
        >
        >     pointcut logCall(Level p) : target(Logger) && args(p) &&
        > !within(LoggingAspect) && call(void log(..));
        >     before(Level p) : logCall(p) {
        >         Errors.add(p);
        >     }
        >
        > If I revise the pointcut and advice as follows it does get applied.
        > AspectJ seems to be getting confused when trying to use arguments and
        > specifying additional optional arguments using wildcards.
        >
        > pointcut logCall() : target(Logger) && !within(LoggingAspect) &&
        > call(void(log(..));
        > before() : logCall() {
        >     dummy();
        > }
        >
        > What's the scoop?  I've also tried the following and it doesn't match
        > either:
        >
        >     pointcut logCall(Level p) : target(Logger) && args(p) &&
        > !within(LoggingAspect) && call(void log(Level, ..));
        >     before(Level p) : logCall(p) {
        >         Errors.add(p);
        >     }
        >
        >
        >
        >
        >
        > _______________________________________________
        > aspectj-users mailing list
        > [email protected] <mailto:[email protected]> 
        > https://dev.eclipse.org/mailman/listinfo/aspectj-users 
<https://dev.eclipse.org/mailman/listinfo/aspectj-users> 
        >
        >   
        _______________________________________________
        aspectj-users mailing list
        [email protected] <mailto:[email protected]> 
        https://dev.eclipse.org/mailman/listinfo/aspectj-users 
<https://dev.eclipse.org/mailman/listinfo/aspectj-users> 
        _______________________________________________
        aspectj-users mailing list
        [email protected]
        https://dev.eclipse.org/mailman/listinfo/aspectj-users
        
        
        
________________________________


        _______________________________________________
        aspectj-users mailing list
        [email protected]
        https://dev.eclipse.org/mailman/listinfo/aspectj-users
          

<<winmail.dat>>

_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to