On Thu, 30 May 2024 18:33:25 GMT, Jonathan Gibbons <j...@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

Reply via email to