RFR: 8332039: Cannot invoke "com.sun.source.util.DocTreePath.getTreePath()" because "path" is null
Jonathan Gibbons
jjg at openjdk.org
Thu May 30 18:40:05 UTC 2024
On Thu, 30 May 2024 18:33:25 GMT, Jonathan Gibbons <jjg at openjdk.org> wrote:
>> Please review a patch to fix a NPE thrown when a `@since` tag inherited by a nested class contains a nested inline tag. The solution is to make `CommentHelper.getDocTreePath(DocTree)` able to handle block tags inherited by nested classes.
>
> src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/CommentHelper.java line 517:
>
>> 515: private DocTreePath getInheritedDocTreePath(DocTree dtree) {
>> 516: Utils utils = configuration.utils;
>> 517: if (element instanceof ExecutableElement ee) {
>
> Technically, it is an official anti-pattern to use `instanceof` on Language Model classes. Yes, it works OK for the JDK implementation of `javax.lang.model`, but it is not necessarily true for all other implementations (with a known instance where it is not the case.)
>
> The recommended solution is to either use visitors or test or switch on the `ElementKind`.
>
> That all being said, I accept this is in JDK code ... and now that we have pattern-switch available ...
On the one hand, I'd like to suggest using pattern-switch -- on the other hand, I note that makes back porting harder.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/19363#discussion_r1621270634
More information about the javadoc-dev
mailing list