title: Generic types in annotations
body: <p>Consider the following code:</p>
  
  <pre><code>import java.lang.annotation.Retention;
  import java.lang.annotation.RetentionPolicy;
  
  public class AnnotationTest {
  
      @GenericAnnotation&lt;String&gt;(foo = "Test")
      public class Bar1 {
  
      }
  
      @ObjectAnnotation(foo = "Test")
      public class Bar2 {
  
      }
  
      @WorkingAnnotation(foo = "Test")
      public class Bar3 {
  
      }
  
      @Retention(RetentionPolicy.RUNTIME)
      public @interface GenericAnnotation&lt;T&gt; {
  
          public T foo();
  
      }
  
      @Retention(RetentionPolicy.RUNTIME)
      public @interface ObjectAnnotation {
  
          public Object foo();
  
      }
  
      @Retention(RetentionPolicy.RUNTIME)
      public @interface WorkingAnnotation {
  
          public String foo();
  
      }
  
  }
  </code></pre>
  
  <p><code>Bar1</code> won't compile at all. Huge mess of errors.</p>
  
  <p><code>Bar2</code> will compile fine, but the <code>ObjectAnnotation</code> annotation won't.</p>
  
  <p><code>Bar3</code> will compile fine, but doesn't allow generic types.</p>
  
  <hr>
  
  <p>If - for example - I am trying to set a default value in case a certain field can't be loaded. This class might be an <code>Integer</code>, <code>String</code>, <code>Boolean[]</code>, really any of the possible types. This means a whole mess of annotations for handling every possibly case. </p>
  
  <hr>
  
  <p>Is there a proper way to handle generic types in an annotation? If not, is there a clear reason why?</p>