java - Error with custom annotation -


i have made custom annotation in java takes 1 value (string[]);

@retention(value = retentionpolicy.runtime) public @interface myannotation{     string[] value (); } 

however, want values-when use myannotation-to this: aclassname.anattribute

  • aclassname name of class in application
  • anattribute 1 of it's attributes string:

    public static string anattribute1="astringxxx";

but error: the value annotation attribute myannotation.value must constant expression have idea please?

if make attribute final work fine.

public class someclass {     public static final string myattribute = "abc"; }  @retention(value = retentionpolicy.runtime) public @interface myannotation {     string[] value(); }  public class someotherclass {     @myannotation({someclass.myattribute})     private int someint; } 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -