Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are 'generated source files' in Java compiler context?

Tags:

java

javac

Oracle documentation on javac says that -s switch is used to specify the directory where to place generated source files. What are those 'generated source files' and why one would need them? I always thought that source files were 'generated' by humanware...

like image 456
Igor Soudakevitch Avatar asked Dec 19 '15 09:12

Igor Soudakevitch


1 Answers

This seems to be related to the Annotation Processing part of javac. Apparently, you can use annotation processors while compiling the humanware-generated source, and those processors may generate source files as part of processing certain annotations:

If any processors generate new source files, then another round of annotation processing occurs: Any newly generated source files are scanned, and the annotations processed as before. Any processors called on previous rounds are also called on all subsequent rounds. This continues until no new source files are generated.

After a round occurs where no new source files are generated, the annotation processors are called one last time, to give them a chance to complete any remaining work. Finally, unless the -proc:only option is used, the compiler compiles the original and all generated source files.

like image 106
RealSkeptic Avatar answered Nov 14 '22 20:11

RealSkeptic