RFR: JDK-8267690: Revisit (Doc)Tree search implemented by throwing an exception

Pavel Rappo prappo at openjdk.java.net
Mon Apr 25 16:27:27 UTC 2022

On Fri, 22 Apr 2022 19:10:38 GMT, Jonathan Gibbons <jjg at openjdk.org> wrote:

> Please review a moderately simple cleanup change, to eliminate using an exception to terminate scanning a `Tree` or `DocTree` in `(Doc)TreePath.getPath`.
> The change is to set a field with the intended result, and once that field is set, do "best-effort" to eliminate any addition scanning.
> It is easy enough to stop scanning items in a list, but it is not practical to totally stop scanning the subsequent sibling nodes, but we can substantially reduce the cost of scanning those nodes, and can definitely avoid scanning any children of those nodes.

I think I'm mistaken: your version does all these things I thought it wasn't doing. What's the difference between it and Jan's version? Is it more responsive wrt termination when the target node is found?

src/jdk.compiler/share/classes/com/sun/source/util/TreePath.java line 69:

> 67: 
> 68:             @Override
> 69:             public TreePath scan(TreePath path, Tree docTree) {

The second parameter has nothing to do with `DocTree`. Copy-paste?


PR: https://git.openjdk.java.net/jdk/pull/8369

More information about the compiler-dev mailing list