2

Let's assume ClassGenerated.java is generated by running the java annotation processor on ClassGeneratedParent.java and ClassA imports both ClassGenerated and ClassGeneratedParent.

When running javac ClassA.java ClassGeneratedParent.java (we don't specify ClassGenerated.java because it should be generated on the fly by javac), ClassA will complaint that it can not find symbol ClassGenerated but the compilation is still successful and we have ClassGenerated.java as well as ClassA.class, ClassGeneratedParent.class, and ClassGenerated.class.

I could split into 2 runs, first run javac -proc:only ClassGeneratedParent.java then javac ClassA.java ClassGeneratedParent.java ClassGenerated.java to avoid the false import compile error but then I'll have to remember which files need to be pre-processed and I don't want to have to remember that. Is there another way to avoid the false import compile error polluting the output of javac?

Long Vu
  • 281
  • 1
  • 10
  • 1
    I'm not sure exactly what you're doing, but you might consider looking at Ant/Maven to control your build process. You can then specify the build order which would theoretically fix your error. It feels a little backwards, but that could just be the way I'm reading it. From my reading here Ant seems like the choice. – Daniel B. Chapman Nov 16 '11 at 22:56
  • If I have to control the build order, then it comes back to doing a 2 phases build, which is what I want to avoid in the first place. I don't want to have to something special with those special files that require pre-processing. – Long Vu Nov 17 '11 at 22:37
  • just to clarify: are you attempting to subclass an automatically generated class? Or, are you attempting to automatically compile a subclass via an Annotation? – Daniel B. Chapman Nov 21 '11 at 14:49
  • I assume subclass means the generated class. I am trying to automatically compile everything (regular classes, subclasses) using one single javac invocation. The build works fine but what really annoys me are the false import errors on the subclasses. – Long Vu Nov 22 '11 at 16:19
  • is it possible for you to post a sample set of code here? I'm happy to look into it, but right now I'm having trouble seeing what's happening. I think I'm visualizing something you are not doing and thus I'm unable to give any input. Your generated classes shouldn't have a problem with what you're describing if you have the class files. – Daniel B. Chapman Nov 23 '11 at 17:17

0 Answers0