title: How to use an array constant in an annotation
body: <p>I would like to use constants for annotation values.</p>
  
  <pre><code>interface Client {
  
      @Retention(RUNTIME)
      @Target(METHOD)
      @interface SomeAnnotation { String[] values(); }
  
      interface Info {
          String A = "a";
          String B = "b";
          String[] AB = new String[] { A, B };
      }
  
      @SomeAnnotation(values = { Info.A, Info.B })
      void works();
  
      @SomeAnnotation(values = Info.AB)
      void doesNotWork();
  }
  </code></pre>
  
  <p>The constants <code>Info.A</code> and <code>Info.B</code> can be used in the annotation but not the array <code>Info.AB</code> as it has to be an array initializer in this place. Annotation values are restricted to values that could be inlined into the byte code of a class. This is not possible for the array constant as it has to be constructed when <code>Info</code> is loaded. Is there a workaround for this problem?</p>