如何通过反射读取Javadoc注释?
我需要知道如何在运行时读取Javadoc注释(可能通过反射?)
假设我有以下函数:
/**
* function that do some thing
*/
public void myFunc()
{
//...
}
在运行时,我可以通过反射获取有关此函数的很多信息..但无法读取注释。所以问题是,如何在运行时读取这个javadoc注释。
I need to know how to read Javadoc comments at run-time (probably by reflection?)
Say I have the following function:
/**
* function that do some thing
*/
public void myFunc()
{
//...
}
At runtime, I can get much information about this function by reflection.. But cannot read the comments. So the question is, How to read this javadoc comments at runtime.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Doclet 类:
和maven执行:
从类路径读取文档:META-INF/apidocs
Doclet class:
And maven execution:
Read docs from classpath:META-INF/apidocs
你不能。它们已从编译的代码中删除。
You can't. They're removed from the compiled code.
考虑使用注释而不是 Javadoc 并编写注释处理器。
Consider to use annotations instead of Javadoc and write an annotation processor.
你不能这样做,因为 javadoc 没有编译成最终类。
You can't do that, cause javadoc isn't compiled into final classes.