Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] pointcut to detect String concatenation at invocation of Log4j?



Phil,

I suspect that any runtime check you introduce will end up being as
expensive as the String concatenation you are trying to avoid. You would do
much better trying to develop a static test that ran as part of the build
however AspectJ is a little "challenged" when it comes to policing
hand-coded policies:
1. You can't detect the absence of a join point (using declare
warning/error) i.e. ensuring the use of the guard.
2. You can't detect the proximity or sequence if join points i.e. log call
follows guard.
3. You can't detect the log is enclosed within a guard as there is no
enclosing join point (noted by Ron).

One thing you can do statically is to either use declare warning or the new
"-showWeaveInfo" flag, capture the output and analyse it to ensure log
calls are matched by guards. The best approach of course is to replace the
current logging implementation with an aspect and enforce its use.

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, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/

"Lee, Philip" <Philip.Lee@xxxxxxxxxxxxx>@eclipse.org on 04/11/2004 15:30:24

Please respond to aspectj-users@xxxxxxxxxxx

Sent by:    aspectj-users-admin@xxxxxxxxxxx


To:    "'aspectj-users@xxxxxxxxxxx'" <aspectj-users@xxxxxxxxxxx>
cc:
Subject:    [aspectj-users] pointcut to detect String concatenation at
       invocation of Log4j?


Hi,

I'm trying to formulate a run time check that catches any unprotected calls
to Log4j that incur the cost of string concatentation

e.g. I want to catch the following and print the line number of the
invocation

             logger.Debug("Problem with op:" + obj);

so that it can be changed to

             if (logger.isEnabledFor(Level.DEBUG))
             {
                         logger.Debug("Problem with op:" + obj);
             }

Is it possible to specify "string concatenation at point of function call"?

TIA,

             Phil.



This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be copied,
disclosed to, retained or used by, any other party. If you are not an
intended recipient then please promptly delete this e-mail and any
attachment and all copies and inform the sender. Thank you.
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users




Back to the top