简体   繁体   中英

Why does @Documented annotation have runtime retention?

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 {
}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM