Why does @Documented annotation have runtime retention?

[亡魂溺海] 提交于 2019-12-22 06:46:56

问题


As I know, @Documented annotation is used only by javadoc generator to generate javadocs from sources. So retention type should be SOURCE, but it's RUNTIME. Why?

@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.ANNOTATION_TYPE)
public @interface Documented {
}

回答1:


IMO that does not explain why @Documented needs runtime retention

Yes, it does. Lets say I ship a jar file without the sources. A user can build a proper javadoc using only information from classfiles the the reason that classfile have proper annotations is becase they are RetentionPolicy.RUNTIME.



来源:https://stackoverflow.com/questions/20775614/why-does-documented-annotation-have-runtime-retention

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!