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
Post a Comment