title: Java pre-processor for sharing code in annotations
body: <p>Attributes in Java annotations have to be completely static expressions, but since the language lacks pre-processing capability, code reuse in annotations are basically non-existent.</p>
  
  <p>For example, there are no alternative for the following use cases:</p>
  
  <pre><code>#define GRANTED {"group1", "group2"}
  
  @Access(granted = GRANTED)
  public void ...
  
  #define USER_HAS_ACCESS(userArg, permissions) "arguments." + userArg + ".hasAccess(" + permissions + ")"
  
  @Access(grantedIf = USER_HAS_ACCESS("usr", "modify"))
  public void modifyData(User usr, Data d) ...
  </code></pre>
  
  <p>In these cases the code replaced by the macro must be re-produced at each location the annotation is used (as there are no array constants and no compile-time string formatting in Java), which is a big maintenance problem.</p>
  
  <p>I am wondering is there any Java pre-processor that works well with Maven?</p>