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

Jonathan Gibbons jjg at openjdk.java.net
Mon Apr 25 20:44:06 UTC 2022


On Mon, 25 Apr 2022 19:03:35 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 additional 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.
>
> Jonathan Gibbons has updated the pull request incrementally with one additional commit since the last revision:
> 
>   improve parameter naming for internal `PathFinder` classes

Thanks for the references to other candidates.

* com.sun.tools.javac.tree.TreeInfo#pathFor seems to be dead code

* com.sun.tools.javac.tree.TreeInfo#containsTypeAnnotation not a path finder, and looks like only called on small trees

* jdk.jshell.ExpressionToTypeInfo#findExpressionPath does seem to be another candidate for this work, but could/should be done separately

-------------

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


More information about the compiler-dev mailing list