Bug 497620

Summary: Annotation parameter bind in @within
Product: [Tools] AspectJ Reporter: ZdzisÅ‚aw Zajebisty <zlooo27>
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3    
Version: 1.8.9   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Zdzisław Zajebisty CLA 2016-07-10 07:56:27 EDT
I have an annotation that can be set on types and methods

@Retention(RetentionPolicy.RUNTIME)
@Target(value = { ElementType.METHOD, ElementType.TYPE })
@Inherited
public @interface MyAnnotation {

  String value() default "";
}

I want to be able to bind value from MyAnnotation as an advice parameter. Following code works ok

  @Around("execution(* *(..)) && @annotation(MyAnnotation(value))")
  public Object aroundMethodLevel(ProceedingJoinPoint point, String value) throws Throwable {

So does this one when I bind annotation

@Around("execution(* *(..)) && @within(myAnnotation)")
  public Object aroundClassLevel(ProceedingJoinPoint point, MyAnnotation myAnnotation) throws Throwable {

However when I try to bind just value using @within instead of whole annotation just like in example using @annotation

@Around("execution(* *(..)) && @within(MyAnnotation(value))")
  public Object aroundClassLevel(ProceedingJoinPoint point, String value) throws Throwable {

compiler claims

[ERROR] the parameter value is not bound in [all branches of] pointcut
        C:\Users\zlooo\workspace\warTest\src\main\java\TestAspect.java:28
@Around("execution(* *(..)) && @within(MyAnnotation(value))")
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^