I am using a annotation processor to process annotations of method parameters.
public void multiply(@IntArg int a){
...
}
The annotations types used for the parameters have an annotation, @Argument
@Retention(RetentionPolicy.CLASS)
@Target({ElementType.PARAMETER})
@Argument
public @interface IntArg {
}
Now, when my annotation processor is running, I want to check if a parameter annotation (@IntArg) has the @Argument annotation. I do this by executing the following code.
VariableElement param = ... //The parameter
for (AnnotationMirror mirror : param.getAnnotationMirrors()) {
Argument arg = mirror.getAnnotationType().getAnnotation(Argument.class);
if(arg != null) {//Args is always null
...
}
}
For some reason arg is always null. Is there a reason why the annotation is not returned?
@Argumentannotation, soargwill be alwaysnull...@Argumentannotation of the parameter, I'm getting the annotation of the AnnotationType, which is IntArg in this case.