Annotation SOURCE Retention Policy

前端 未结 2 1335
無奈伤痛
無奈伤痛 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:54

    This answer makes perfect sense - https://stackoverflow.com/a/43910948/3009968.

    You would not like to include a dependency, the desired effects of which are realized even before the code is compiled. E.g. @SuppressWarnings

    You would not like to include a dependency which is used by compiler to let's say generate code but not at all required during runtime. E.g. as mentioned already in previous answer -spring roo.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题