[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [aspectj-users] parameter evaluation and advice
|
:: Consider the following advice:
::
:: void around(Logger aLog) :
:: call(public * Logger.debug(..))
:: && target(aLog) {
:: if (aLog.isDebugEnabled()) {
:: proceed(aLog);
:: }
:: }
::
:: This advice works as expected - it prevents calls to
:: log.debug(myString) from executing if log is not debugEnabled.
::
:: However, testing for a side effect on myString or examining
:: byte code reveals that the parameter to the debug() method
:: ('myString') is being evaluated, even if log is not debugEnabled and
:: proceed() is never called.
::
:: I'm not familiar with how AspectJ is implemented, but... is
:: there a way to prevent parameter evaluation in this example?
to do this you need a fully dynamic system with proper macro support (a
system/language where code = data is practically true, and has runtime
eval/compile). if you are willing to invest in learning more about the
possibilities you can find a lot of good reading at
http://cliki.tunes.org/index the Learning Lounge section contains a
structured info that you can read/skip base don your knowledge.
i don't say that it couldn't be done by the brilliant aspectj team, but
it would mean partially implementing such a dynamic system (?). i would
be more than happy to see macros/eval/compile in java, but there's
little probability of that.
<dreaming>
oh, well. if only java were not bootstrapped by a VM written in a
different language, but instead a fully self contained system that has
code as first class objects and can generate executables for different
platforms by it's compiler written in itself. but that would be a
different story, a different language...
</dreaming>
101