RFR: JDK-8312044: Simplify toolkit Builder/Writer world.
Jonathan Gibbons
jjg at openjdk.org
Tue Jul 18 14:59:49 UTC 2023
Please review a medium-sized but conceptually simple change to simplify the overall class hierarchy of the `doclet` world.
As described in detail in the JBS entry, the classes in `toolkit.builder.*Builder` and corresponding writer interfaces in `toolkit.*Writer` provide little useful benefit, and only serve to clutter a somewhat chaotic situation.
In this patch, the following is done:
* the `builder` methods in `toolkit/builders/---Builder.java` are moved into the corresponding `formats/html/---WriterImpl.java` class. Generally, the insertion was done "early" in the file, typically after the constructor(s).
* the `writer` interfaces in `toolkit/---Writer.java` are deleted and references to them in `implements` clauses removed.
* the `writer` classes in `formats/html/---WriterImpl.java` are renamed to `formats/html/---Writer.java` and in a couple of anomalous cases, the `writer` classes in `formats/html/Html---Writer.java` are also renamed to `formats/html/---Writer.java`.
* the markup root class `Content` no longer needs to be in `toolkit` and is moved to `formats/html`. (It's a close call whether it is better there or in `formats/html/markup`.
* Because of the class renaming, one test had to be updated; no other tests were affected by these changes.
* Because of the class renaming, the `<meta name="generator" ...>` information changes; there are no other changes to the generated JDK API documentation.
The changes to the `doclets` class hierarchy are shown in two attachments in the JBS entry. In those images, you can see the "clutter" of the `builder` world and `writer` world being simplified.
The following tables show the changes in the number of files and the number of lines of code resulting from this refactoring.
### # files
| | before | after | change | %before |
|-------------:|-------:|------:|-------:|--------:|
| toolkit | 79 | 46 | -33 | 58% |
| formats/html | 108 | 109 | 1 | 101% |
| doclets | 189 | 157 | -32 | 83% |
### # lines of code
| | before | after | change | %before |
|-------------:|-------:|------:|-------:|--------:|
| toolkit | 21445 | 15597 | -5848 | 73% |
| formats/html | 29805 | 31968 | 2163 | 107% |
| doclets | 51325 | 47640 | -3685 | 93% |
This generally completes the recent large-scale refactoring and simplification that was started in
[JDK-8309566](https://bugs.openjdk.org/browse/JDK-8309566). While large-scale refactoring like this may be hard to review, and complicate any future code-archaeology and back-porting, in this case the benefits of the simplification outweigh any future costs of not doing it.
Now that some of the clutter has been moved away, we may be able to retrofit some abstract members to root classes like `HtmlDocletWriter` and `AbstractMemberWriter`. For example, `HtmlDoclet` should be able to call a common/standard method to generate each (kind of) page, and likewise, `SubWriterHolderWriter` should be able to call a common/standard method to handle each kind of member. See [JDK-8312201](https://bugs.openjdk.org/browse/JDK-8312201) for a follow-up issue.
-------------
Commit messages:
- fix metadata test after class renaming
- fix minor build issue
- Merge remote-tracking branch 'upstream/master' into 8312044.builder-writer
- Initial checkin, after initial merge of builders and writer classes and interfaces
- Initial checkin, after initial merge of builders and writer classes and interfaces
Changes: https://git.openjdk.org/jdk/pull/14913/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14913&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8312044
Stats: 14868 lines in 133 files changed: 5517 ins; 9214 del; 137 mod
Patch: https://git.openjdk.org/jdk/pull/14913.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/14913/head:pull/14913
PR: https://git.openjdk.org/jdk/pull/14913
More information about the javadoc-dev
mailing list