简体   繁体   English

运行时保留Javadoc元数据?

[英]runtime retention of Javadoc metadata?

Is there any way to access Javadoc information via reflection, the way annotations can be retained at runtime? 有没有办法通过反射访问Javadoc信息,注释的方式可以在运行时保留?

If not, how does Eclipse access the javadoc for .jar files? 如果没有,Eclipse如何访问.jar文件的javadoc?

JavaDoc is not available via reflection. JavaDoc不能通过反射获得。 Eclipse and other IDE's access jar files with JavaDoc for libraries where this is available. Eclipse和其他IDE使用JavaDoc访问jar文件,以获取可用的库。 Ie if you use maven, jar files with JavaDoc is usually distributed along with jar files with the byte code. 即如果你使用maven,带有JavaDoc的jar文件通常与带有字节代码的jar文件一起分发。

Comments used for Javadoc are never retained in compiled classes (see http://java.sun.com/docs/books/jvms/second_edition/ClassFileFormat-Java5.pdf for instance). 用于Javadoc的注释永远不会保留在已编译的类中(例如,请参阅http://java.sun.com/docs/books/jvms/second_edition/ClassFileFormat-Java5.pdf )。 Eclipse is able to associate Javadoc to the referenced jar files either by extracting it from the jar (if present), by direct association with the jar file (set by yourself or a plugin like m2eclipse), or by finding it inside the JRE javadoc (set directly in "Installed JREs"). Eclipse能够通过从jar文件(如果存在)中提取它,通过直接关联jar文件(由你自己设置或像m2eclipse这样的插件),或者通过在JRE javadoc中找到它来将Javadoc与引用的jar文件相关联(直接在“已安装的JRE”中设置。

You may use this tool to access Javadoc at runtime via annotations. 您可以使用此工具在运行时通过注释访问Javadoc。 It runs as annotation processor and generates @Description annotations at compile time. 它作为注释处理器运行,并在编译时生成@Description注释。 https://github.com/Devexperts/dgen https://github.com/Devexperts/dgen

In theory, it would be possible to have a javadoc doclet which is modifying the classes from the javadoc tags, adding some annotations to the documented elements. 从理论上讲,可以使用javadoc doclet修改javadoc标记中的类,为记录的元素添加一些注释。

But I don't know of any such doclet (which would also have to include some annotation types for runtime use). 但我不知道任何这样的doclet(它还必须包含一些注释类型以供运行时使用)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Checker 框架 - 运行时保留 - Checker framework - runtime retention 在具有运行时保留的对象上找不到注释 - Annotation not found on object with Runtime retention 默认情况下,将批注配置为RUNTIME保留(没有单独的@Retention) - Configuring Annotations to be RUNTIME Retention By Default (without individual @Retention) 如何使用 Javadoc 记录 function 的运行时间 - How to document runtime of a function with Javadoc 为什么@FunctionalInterface具有RUNTIME保留? - Why does @FunctionalInterface have a RUNTIME retention? 为什么@Documented注释具有运行时保留? - Why does @Documented annotation have runtime retention? Java运行时保留批注-在编译时需要批注类,但在运行时不需要吗? - Java runtime retention annotations - annotation class required at compile time but not at runtime? Java自定义注解的Processor代码什么时候调用? (运行时保留) - When the Processor code of Java Custom Annotation is called? (runtime retention) 如果覆盖的保留策略是源,那么运行时多态如何工作 - How runtime polymorphism work if retention policy of override is source Java运行时保留批注在以前的Java版本中的兼容性 - Compatibility of a Java runtime retention annotation in previous Java versions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM