Community
Participate
Working Groups
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.
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)