title: Compiler says an annotation's "value must be a constant"
body: <p>I have a Spring<sup>1</sup> <code>@Controller</code> annotated class with <code>@RequestMapping</code> annotated methods. I want to reference values for the <code>@RequestMapping</code> parameters, <code>value</code> and <code>method</code>, from another class, rather than hard coding them into the annotation.</p>
  
  <h3>Example</h3>
  
  <p>Instead of</p>
  
  <pre><code>@Controller
  public class MyController {
      @RequestMapping(value="my/path", method=RequestMethod.GET)
      public String handlePath() {
          // etc...
      }
  }
  </code></pre>
  
  <p>I want two files,</p>
  
  <pre><code>@Controller
  public class MyController {
      @RequestMapping(value=Constants.PATH, method=Constants.PATH_METHOD)
      public String handlePath() {
          // etc...
      }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public class Constants {
      public static final String PATH = "my/path";
      public static final RequestMethod PATH_METHOD = RequestMethod.GET;
  }
  </code></pre>
  
  <p>Unfortunately, this fails with the following compile-time error:</p>
  
  <pre class="lang-none prettyprint-override"><code>error: an enum annotation value must be an enum constant
          @RequestMapping(value=Constants.PATH, method=Constants.PATH_METHOD)
                                                                ^
  </code></pre>
  
  <h3>Question</h3>
  
  <p>Why does this work in the case of <code>String</code> but does not work for <code>enum</code>s?</p>
  
  <hr>
  
  <h3>Notes</h3>
  
  <ol>
  <li>This question is not Spring specific, this is just an (hopefully) accessible example of this issue.</li>
  <li>I happen to be using Java 8</li>
  </ol>