jeudi 5 juillet 2018

Write an Annotation Processor to make all method args FINAL

I am trying to an annotation processor to implicitly make particular method(annotated) arguments final?

My Annotation:

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface MakeFinal_Args {

}

and my annotation processor looks like this:

@SupportedAnnotationTypes("com.walmart.annotations.MakeFinal_Args")
public class Processor extends AbstractProcessor {

    private ProcessingEnvironment env;

    @Override
    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
        Class<?> clazz = Runtime.getRuntime().getClass();

        for (Parameter parameter : clazz.getEnclosingMethod().getParameters()) {
            parameter.
        }
        return true;
    }
}

Stuck here.Need help with the same. Thanks in advance.





Aucun commentaire:

Enregistrer un commentaire