On Thu, 29 Aug 2024 20:10:13 GMT, Jonathan Gibbons <j...@openjdk.org> wrote:
> Please review an update to "clean up" the direct use of HtmlTree constructors. > > Hitherto, many/most instances of `HtmlTree` were created by static factory > methods. This update extends that convention. > In most cases, this is by providing either simple no-arg factory methods or > commonly used overloads that take an `HtmlId` or `HtmlStyle`. > > For some tags, (`br`, `hr`, `wbr`) this allows a singleton instance to be > used. > For some of the more obscure cases, a more generic `HtmlTree.of(HtmlTag)` > method was used. > > Notes: > * some significant block-level nodes, like `pre`, should probably always set > a style, which could be enforced by suitable factory methods. That is > currently not the case and could be a future cleanup. > * some lists put the same style info on each list item, but might be better > placed on the enclosing list. That could be a future cleanup src/jdk.javadoc/share/classes/jdk/javadoc/internal/html/HtmlTree.java line 389: > 387: } > 388: > 389: private static HtmlTree BR_INSTANCE = unmodifiableTree(HtmlTag.BR); There is a failing test in `tools/javac/T8003967/DetectMutableStaticFields.java` because of this and the other new static fields in `HtmlTree.java` not being `final`. The fields should be declared as `final` anyway. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/20778#discussion_r1740572857