In the below case a tree is searched for a specific node: https://github.com/openjdk/jdk/blob/739769c8fc4b496f08a92225a12d07414537b6c0/src/jdk.compiler/share/classes/com/sun/source/util/DocTreePath.java#L61
If the node is found, the search is terminated by throwing an exception containing that node: https://github.com/openjdk/jdk/blob/739769c8fc4b496f08a92225a12d07414537b6c0/src/jdk.compiler/share/classes/com/sun/source/util/DocTreePath.java#L77
The exception is then caught and the contained node is returned as the result of the search: https://github.com/openjdk/jdk/blob/739769c8fc4b496f08a92225a12d07414537b6c0/src/jdk.compiler/share/classes/com/sun/source/util/DocTreePath.java#L90
Such use of exceptions is counterintuitive and should be avoided. (See, for example, Item 69: Use exceptions only for exceptional conditions; Effective Java, Third Edition)
For the record: "make docs-jdk-api" results in approximately 220,000 of such exceptions being created and thrown.
If the node is found, the search is terminated by throwing an exception containing that node: https://github.com/openjdk/jdk/blob/739769c8fc4b496f08a92225a12d07414537b6c0/src/jdk.compiler/share/classes/com/sun/source/util/DocTreePath.java#L77
The exception is then caught and the contained node is returned as the result of the search: https://github.com/openjdk/jdk/blob/739769c8fc4b496f08a92225a12d07414537b6c0/src/jdk.compiler/share/classes/com/sun/source/util/DocTreePath.java#L90
Such use of exceptions is counterintuitive and should be avoided. (See, for example, Item 69: Use exceptions only for exceptional conditions; Effective Java, Third Edition)
For the record: "make docs-jdk-api" results in approximately 220,000 of such exceptions being created and thrown.
- relates to
-
JDK-8285396 Do not fill in the stacktrace of an internal exception
-
- Closed
-
-
JDK-8285610 TreeInfo.pathFor and its uses appear to be dead code
-
- Resolved
-
-
JDK-8285619 shell ExpressionToTypeInfo.findExpressionPath uses exceptions
-
- New
-