Bug 497620 - Annotation parameter bind in @within
Summary: Annotation parameter bind in @within
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.8.9   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-10 07:56 EDT by Zdzisław Zajebisty CLA
Modified: 2016-07-10 07:56 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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))")
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^