Annotation SOURCE Retention Policy

前端 未结 2 1360
無奈伤痛
無奈伤痛 2021-01-01 11:08

From the Java doc:

CLASS: Annotations are to be recorded in the class file by the compiler but need not be retained by the VM at run time.

RUNTIME:

2条回答
  •  感动是毒
    2021-01-01 11:57

    Things like @SuppressWarnings, @Override are annotations used by the compiler - not needed at runtime. For those RetentionPolicy.SOURCE would make sense. Also annotations can be used to generate code (look at Spring ROO) - such annotation are also not required at run time.

提交回复
热议问题