Best way to get com.sun.source.doctree.DocTree?

Harry Terkelsen het at
Tue Sep 30 23:06:10 UTC 2014

Hi compiler devs,

I would like to use the DocTree API for JavaDoc comments but I don't see
any way to get a DocTree from a JavaDoc comment?

Is there any way to simply parse a JavaDoc comment, given as a String,
along with the start and end positions in the original source, and get back
a DocTree with source positions properly set? In other words, is it
possible to write this method:

DocTree parseDocTree(String comment, int pos, int endPos);

If that is not possible, I see that I can go from TreePath ->
DocCommentTree with DocTrees#getDocCommentTree(TreePath) but I'm assuming
this is only for JavaDoc comments that are attached to top-level program
elements. Is this the only way to get DocTrees?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the compiler-dev mailing list