Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] It was related to inheritance and deprecated methods ...

I would guess that your first pointcut doesn't match because while a Level "is a" Priority, a Priority is not a Level. As for why a runtime test, target() is used to capture the context at the join point. If you are not using "target(Logger log)" to bind the target, it might be possible to avoid the runtime check by using "call(void Logger.log(..))"
Elizabeth
-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx]On Behalf Of Glenn Farrow
Sent: September 19, 2006 11:51 AM
To: Matthew Webster
Cc: aspectj-users@xxxxxxxxxxx
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



CONFIDENTIAL AND PRIVILEGED INFORMATION NOTICE

This e-mail, and any attachments, may contain information that
is confidential, subject to copyright, or exempt from disclosure.
Any unauthorized review, disclosure, retransmission, 
dissemination or other use of or reliance on this information 
may be unlawful and is strictly prohibited.  

AVIS D'INFORMATION CONFIDENTIELLE ET PRIVILÉGIÉE

Le présent courriel, et toute pièce jointe, peut contenir de 
l'information qui est confidentielle, régie par les droits 
d'auteur, ou interdite de divulgation. Tout examen, 
divulgation, retransmission, diffusion ou autres utilisations 
non autorisées de l'information ou dépendance non autorisée 
envers celle-ci peut être illégale et est strictement interdite.

Back to the top