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