What is the meaning of defining enums and fields inside annotation declarations?

Mário Guimarães mario.luis.guimaraes at gmail.com
Thu Apr 20 16:32:34 UTC 2017


 Hello,

It seems it is possible to declare fields and enums inside the declaration
of an annotation in Java. For example, javac compiles this:

 @interface ClassPreamble {
   public enum AnEnum {
        Value;
   }
   String aField = "";

   String author();
   String date();
   String currentRevision() default "";
   String lastModified() default "N/A";
   String lastModifiedBy() default "N/A";
   // Note use of array
   String[] reviewers();}

What is the meaning / usefulness of defining enums and fields inside
annotation declarations?

Thanks

Mário
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20170420/ef53e7a6/attachment.html>


More information about the compiler-dev mailing list