i have written custom annotation below:
package annotation; import static java.lang.annotation.elementtype.method; import java.lang.annotation.retention; import java.lang.annotation.retentionpolicy; import java.lang.annotation.target; @retention(retentionpolicy.runtime) @target(method) public @interface fieldrule { string value(); }
and class utilize annotation is:
package annotation; public class screeningvo { string rrcstatuscode; public string getrrcstatuscode() { return rrcstatuscode; } @fieldrule("rrc_rule") public void setrrcstatuscode(string rrcstatuscode) { this.rrcstatuscode = rrcstatuscode; } public static void main(string[] args) { screeningvo s = new screeningvo(); s.setrrcstatuscode("yes"); system.out.println("testing annotation"); } }
now when compile screeningvo compiler throws error:
screeningvo.java:11: error: cannot find symbol @fieldrule("rrc_rule") ^ symbol: class fieldrule location: class screeningvo
however annotation provided , both annotation , screeningvo exist in same package.
Comments
Post a Comment