I have an interface like this
@MyAnnotation
public interface Foo {
public String methodA();
public String methodB();
}
I'd like, at compilation time, to add some constant filed to this interface without modifying the source code
@MyAnnotation
public interface Foo {
static final String METHOD_A = "methodA";
static final String METHOD_B = "methodB";
String methodA();
String methodB();
}
so in the code I can use Foo.METHOD_A
event though the constant is not defined (like Lombok)
I've foude some examples using AnnotationProcessors (https://gist.github.com/pietrocaselani/8624554 or https://github.com/sockeqwe/annotationprocessing101) but they seem to use com.sun.tools.javac
that is for java8 and i dont seem to find an alternative for java11