为什么@Documented注释具有运行时保留? [英] Why does @Documented annotation have runtime retention?
本文介绍了为什么@Documented注释具有运行时保留?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道,@Documented
批注仅由javadoc生成器使用以从源生成javadocs.因此保留类型应为SOURCE
,但应为RUNTIME
.为什么?
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 {
}
推荐答案
无法解释@Documented为什么需要运行时保留的IMO
IMO that does not explain why @Documented needs runtime retention
是的,确实如此.可以说我运送了一个没有源文件的jar文件.用户可以仅使用类文件中的信息来构建适当的javadoc,因为类文件具有适当的批注的原因是它们是RetentionPolicy.RUNTIME.
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.
这篇关于为什么@Documented注释具有运行时保留?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文