I'm currently at a project where I work with Java's custom annotations. I want to force the user of my annotation that he has to declare at least a final boolean b
inside the method parameters list if he has annotated the method with @Foo. So it should look something like this:
@Foo
public void foo(final boolean b) { }
@Foo
public void bar() { } // This should result in an error
With my annotation processor I can retrieve the type of the variable but not the final modifier. If i want to retrieve the set of modifiers as shown in the below code, the set will always be empty although the final modifier is present on the parameter.
for (VariableElement parameter : method.getParameters()) {
Set<Modifier> modifiers = parameter.getModifiers(); // This set is always empty
}
Any ideas, why this is the case?