RFR: 8267329: Modernize Javadoc code to use instanceof with pattern matching [v3]
Jonathan Gibbons
jjg at openjdk.java.net
Wed May 19 22:09:41 UTC 2021
On Wed, 19 May 2021 19:19:24 GMT, Ian Graves <igraves at openjdk.org> wrote:
>> src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkOutputImpl.java line 54:
>>
>>> 52: @Override
>>> 53: public void append(Object o) {
>>> 54: output.append(o.toString());
>>
>> There may be a change in behavior here, for "invalid" arguments, which will now use `.toString()` instead of throwing CCE.
>
> My first reaction is in agreement, but upon further inspection it seems that this class is not used by anything in the module. Interestingly its documentation header warns not to rely on its behavior to remain the same.
The documentation header is a standard langtools warnings to all those people that rely on access to javac and javadoc internals.
Class not used ... wow, correct. I'll file an RFE to investigate and remove it.
>> src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/ContentBuilder.java line 72:
>>
>>> 70: } else {
>>> 71: contents.add(tb = new TextBuilder());
>>> 72: }
>>
>> Restructure this
>>
>> contents.add((c instanceof TextBuilder tb) ? tb : new TextBuilder());
>>
>> or something similar
>
> Unclear if there's a more succinct way to refactor this like so. If `c` is not an instance of `TextBuilder` then we need to initialize a new `TextBuilder` and add it to `contents`. This is not the case if `c` is already of the desired instance.
Then just a shorter name than `txtBldr` please. Lvng t vwls s nt - jvdc cnvntn.
-------------
PR: https://git.openjdk.java.net/jdk/pull/4105
More information about the javadoc-dev
mailing list