title: How do I use Annotation Processing API in runtime?
body: <p>I have and followed several Annotation Processing Tool (APT) guides (such as <a href="http://deors.wordpress.com/2011/10/08/annotation-processors/" rel="noreferrer">1</a> and <a href="http://blog.christoffer.me/2011/08/how-to-enforce-static-methods-on-class.html" rel="noreferrer">2</a>) on the Internet and have managed to get it working in compiler/ build time, and even got it working in Eclipse.</p>
  
  <p>Is there a way I can use APT in run time to get a list of Types (Classes) using my annotation.</p>
  
  <p>I wrote something like:</p>
  
  <pre><code>@SupportedAnnotationTypes("com.domain.MyAnnotation")
  public class MyAbstractProcessor extends AbstractProcessor {
  
      public static Map&lt;Element, MyAnnotation&gt; patches = new HashMap&lt;Element, MyAnnotation&gt;();
  
      @Override
      public boolean process(final Set&lt;? extends TypeElement&gt; annotations, final RoundEnvironment roundEnvironment) {
  
          // Get all classes that has the annotation
          Set&lt;? extends Element&gt; classElements = roundEnvironment.getElementsAnnotatedWith(MyAnnotation.class);
  
          // For each class that has the annotation
          for (final Element classElement : classElements) {
  
              patches.put(classElement, annotation);
  </code></pre>
  
  <p>So MyAbstractProcessor.patches would be populate with a list of classes using the annotation. A noble idea, apart from the flaw that this APT is executing at build time, and not run time.</p>
  
  <p>Is it even possible to use APT in run time?</p>
  
  <p>Or am I using the wrong frameworks to get what I want?</p>