RFR: JDK-8267394: Do not rely on object identity for empty valid Content instance

Hannes Wallnöfer hannesw at openjdk.java.net
Tue Jun 1 10:04:18 UTC 2021


On Thu, 20 May 2021 14:31:33 GMT, Hannes Wallnöfer <hannesw at openjdk.org> wrote:

> This is a simple cleanup to replace the sentinel `HtmlTree.EMPTY` text constant with an instance that achieves the same by overriding `isValid()`. I think this is the nicer solution, and it allows us to remove the special case identity check in `HtmlTree.add(Content)`.

I compared output for JDK API docs before and after this patch, they are bit-for-bit identical. This is what I would have expected, since `HtmlTree.add(Content)` is pretty much the only relevant place where `Content.isValid()` is invoked (apart from some peripheral writers, and as of JDK-8267219, `ContentBuilder.isValid()`).

> I agree with Jon on that this change should be tested thoroughly. I recommend that you compare outputs of JDK API documentation in addition to running usual tier1 tests. That said, I think I understand what you are trying to achieve with this change: it might be useful to have that "special empty" behavior implemented in a more versatile way which allows both structured and OOP treatment.

-------------

PR: https://git.openjdk.java.net/jdk/pull/4130


More information about the javadoc-dev mailing list