[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Conditional Compilation and AspectJ


More importantly your classes have not been woven with the advice reducing
overall code size and eliminating pathlength. If no advice is being called
at all then don't include the aspect with your application thereby removing
all overhead.

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

"neil loughran" <n.loughran@xxxxxxxxxxxxxxx>@eclipse.org on 25/11/2004

Please respond to aspectj-users@xxxxxxxxxxx

Sent by:    aspectj-users-admin@xxxxxxxxxxx

To:    <aspectj-users@xxxxxxxxxxx>
Subject:    [aspectj-users] Conditional Compilation and AspectJ

Hi all,

One of the features missing from the java language is a pre-processor to
handle conditional compilation.  Many people will point out that this was
only really needed in C++ to handle different platforms and that its
possible to imitate #ifdef kind of constructs using static variables, which
is how the guys at Philips reduce their preprocessing directives for their
Koala component technology.


private final static boolean DEBUG = true;


        ... some functionality

whereby setting DEBUG  as a static variable would cause the compiler to
include the code or not.
I've been wondering if it is possible to do the same thing in AspectJ on
advice, whereby the compiler would know that the branches could not be
reached so would not include them.

I put together a simple aspect as shown below

aspect X

    private final static boolean CHECK = false;

    pointcut something() : call (public void SomeClass.printMsg(String));
    pointcut check() : if(CHECK);

    before() :something() && check()
        //.. some functionality

but found after checking the bytecode that the compiler converted the
advice into a method even though it would never get executed.

Is there a reason for this?