Bug 220285 - support annotation value matching
Summary: support annotation value matching
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.6.0M1   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P2 enhancement (vote)
Target Milestone: 1.6.0 M2   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-25 16:51 EST by Andrew Clement CLA
Modified: 2008-02-25 20:12 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Clement CLA 2008-02-25 16:51:23 EST
There is a need sometimes to determine statically (at weave time) whether an annotation has a particular value.  If it can be determined at weave time rather than using reflection code within the advice, certain scenarios can be optimized.  For example, this trace annotation

enum Level { NONE, LEVEL1, LEVEL2 }
@interface Trace { 
  Level level() default Level.Level1;
}

Without the ability to match on annotation values statically, if we came across this method and advice

@Trace(Level.NONE) public void criticalMethod() {}

before(): execution(@Trace * *(..)) {}

we would have to do reflection in the advice just to discover we shouldn't be tracing.  If that scenario could be matched entirely statically:

before(): execution(@Trace !@Trace(Level.NONE) * *(..)) {}

then we can avoid weaving the criticalMethod() in the first place.
Comment 1 Andrew Clement CLA 2008-02-25 20:12:04 EST
implemented and committed.  The primary use case intended to be addressed is supported.  What is not yet implemented is:

- parameter annotation value matching
- support for annotation values of type Array or Class (all the others are supported: primitives, string, enum)