title: Annotation Processing Compilation Steps
body: <p>I read in this article(<a href="https://www.javacodegeeks.com/2015/01/how-to-process-java-annotations.html" rel="nofollow noreferrer">https://www.javacodegeeks.com/2015/01/how-to-process-java-annotations.html</a>) that Annotation Processing has multiple rounds:</p>
  <blockquote>
  <p>Annotation processing happens in separate stages, called rounds. During each round, a processor gets a chance to process the annotations it is interested in.</p>
  <p>The annotations to process and the elements they are present on are available via the RoundEnvironment parameter passed into the process() method.</p>
  <p>If annotation processors generate new source or class files during a round, then the compiler will make those available for processing in the next round. This continues until no more new files are generated.</p>
  <p>The last round contains no input, and is thus a good opportunity to release any resources the processor may have acquired.</p>
  </blockquote>
  <p>Can someone explain to my what it means by rounds? So for example let's say we have an annotation <code>Metrics.java</code>, when the compiler is parsing through the java source code it will first find all the elements that use this annotation and then at the end of compilation run the annotation process for that specific <code>Metrics</code> annotation where the <code>RoundEnvironment</code> passed in will contain all the elements that have the <code>Metrics</code> annotation?</p>
  <p>Or anytime the compiler sees a annotation it will immediately run the annotation if it has a retention type of <code>Class</code> or <code>Source</code>. Otherwise it will not run the annotation for that annotation until runtime since it has a retention type of <code>Runtime</code>?</p>