0

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 /org/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!

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.