[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [aspectj-users] Conditional Compilation and AspectJ
- From: Matthew Webster <matthew_webster@xxxxxxxxxx>
- Date: Fri, 26 Nov 2004 15:06:21 +0000
- Delivered-to: firstname.lastname@example.org
- Importance: Normal
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
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
Subject: [aspectj-users] Conditional Compilation and AspectJ
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
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?