RFR: JDK-8252712: move doclint to jdk.javadoc module [v2]
Hannes Wallnöfer
hannesw at openjdk.java.net
Tue Sep 22 11:36:20 UTC 2020
On Thu, 17 Sep 2020 17:25:15 GMT, Jonathan Gibbons <jjg at openjdk.org> wrote:
>> doclint is a component that can check documentation comments, that can be invoked from either javac or javadoc, via the
>> `-Xdoclint` family of options.
>> When JDK was modularized in JDK9, doclint was left in the `jdk.compiler` module because of direct references to the
>> code from javac, even though functionally the code more naturally belongs in the `jdk.javadoc` module.
>> This change moves the code into the `jdk.javadoc`, using a service/provider API to make the functionality available to
>> javac. This should be completely transparent, as long as the `jdk.javadoc` module is available when performing service
>> binding. If it is not available, a default no-op implementation is automatically used instead. One minor complication:
>> the old code used static methods on the `DocLint` class to validate options. This is no longer possible when using the
>> service provider mechanism. Instead, the methods are changed to instance methods. The javac `Option` enum has no way to
>> cleanly cache an instance of the service provider class, and so a new instance is created for each option. However,
>> this is a relatively lightweight operation, and can reasonably be done for the typically few doclint-related options on
>> the command line. Note: JShell has been making minor use of an internal doclint class enum `HtmlTag`, which is no
>> longer easily available. A minimal local enum is left behind in JShell's `JavadocFomatter` class, sufficient to its
>> requirements. Since the dominant use of the enum is in `switch` statements, an alternative solution, avoiding the local
>> enum, would be to use strings and _switch on string_ instead. However, the use of the local enum is a smaller
>> disturbance to the `JavadocFormatter` class.
>
> Jonathan Gibbons has updated the pull request with a new target base due to a merge or a rebase. The pull request now
> contains four commits:
> - Merge master
> - Merge
> - move doclint to jdk.javadoc module
> - add DocTrees.getCharacters(EntityTree)
Changes look good apart from minor issues addressed in extra comments.
src/jdk.compiler/share/classes/com/sun/tools/doclint/DocLint.java line 1:
> 1: package com.sun.tools.doclint;
Why is there no copyright header in this file?
src/jdk.compiler/share/classes/jdk/internal/shellsupport/doc/JavadocFormatter.java line 127:
> 125: }
> 126:
> 127: enum HtmlTag {
What was the criterion for choosing this subset of HtmlTag values? It seems the only ones actually used by this class
are HTML, TABLE, TH, and LI.
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java line 1265:
> 1263:
> 1264: if (name != null) {
> 1265: jdk.javadoc.internal.doclint.HtmlTag htmlTag = jdk.javadoc.internal.doclint.HtmlTag.get(name);
Is there a reason not to import the HtmlTag class?
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/DocLint.java line 2:
> 1: /*
> 2: * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
Copyright year should be updated
-------------
PR: https://git.openjdk.java.net/jdk/pull/133
More information about the compiler-dev
mailing list