I am currently in a project where I work with custom Java annotations. I want to force the user of my annotation that he should declare at least final boolean b in the method parameter list if he annotated the method with @Foo. Therefore, it should look something like this:
@Foo public void foo(final boolean b) { } @Foo public void bar() { }
With my annotation processor, I can get the type of a variable , but not the last modifier . If I want to get a set of modifiers, as shown in the code below, the set will always be empty, although the last parameter is present in the parameter.
for (VariableElement parameter : method.getParameters()) { Set<Modifier> modifiers = parameter.getModifiers();
Any ideas why this is so? Did I miss something?
source share