javac annotation processor : processing dependency classes
Let's imagine that I have 2 classes in 2 different packages.
Ex:
package org.example;
public ClassA {
@MyAnnotation
public void xpto() {
ClassB.staticMethod();
}
}
package org.another;
public ClassB {
public void staticMethod() {
//
}
@MyAnnotation
public x1() {
}
}
Inside ClassA there is a method with a reference to a ClassB static method.
Now I have a javac process with an annotation processor which will compile every class of /or开发者_开发百科g/example/**
When javac compiles ClassA it will find ClassB as dependence so it will have to compile ClassB too. Does the ClassB will be processed ?
I guess not and I need it to be, do you know how to do it ?
Thanks!
Well, the answer is quite simple : if ClassB is in the source path, it well be processed. If not, it won't. The fact the ClassA class a method from ClassB doesn't change anything.
The easiest way to check is to print the list of annotated classes given to your processor.
精彩评论