8287379: Using @inheritDoc in an inapplicable context shouldn't crash javadoc#54
8287379: Using @inheritDoc in an inapplicable context shouldn't crash javadoc#54pavelrappo wants to merge 13 commits intoopenjdk:masterfrom pavelrappo:8287379
Conversation
We can do this safely because the `trees` parameter is never null in any of the 3 call sites of the checkTags method.
The `element` cannot be null for various reasons: 1. If `element` were null, `getCommentHelper` would NPE (because it calls `Utils.getDocCommentInfo` which NPEs on a null element). 2. The Overview and Html files correspond to the OverviewElement and DocFileElement pseudo-elements, which are passed to checkTags when respective files are processed. Existing tests and ad-hoc experiments support that.
Aside from @inheritdoc, which is context-dependent, we now have a bimodal tag such as {@return}/@return.
overview.html and doc-files/**/*.html files cannot have a main description or be an empty comment. At the very least, the check for being "an empty comment" for such files cannot be performed by checking if the files contain any block tags. Block tags are applicable to a program element, which those files are not.
The type of a declaration (module, class or interface, constructor, method, etc.) for which a tag is applicable, is orthogonal to the type of the tag (inline, block, bimodal). The code up the stack knows which type of tags it has collected. If those tags are of type other than expected, it's a programming error.
This undoes undocumented changes introduced by 8008768.
1. Removes @inheritdoc from these type of declarations: * class and interface * constructor 2. Removes empty declarations. 3. Updates @APinote, @implSpec and @implNote definitions to match those of JDK API. 4. Fixes a few typos.
|
/csr |
|
👋 Welcome back prappo! A progress list of the required criteria for merging this PR into |
|
@pavelrappo this pull request will not be integrated until the CSR request JDK-8288841 for issue JDK-8287379 has been approved. |
|
@pavelrappo The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
jonathan-gibbons
left a comment
There was a problem hiding this comment.
It worries me that we are removing support for a feature that had explicit positive tests.
|
|
||
| // Checks if the passed tree path does NOT correspond to an entity, such as | ||
| // the overview file and doc-files/**/*.html files. | ||
| private boolean notPseudoElement(TreePath p) { |
There was a problem hiding this comment.
The use of a predicate named not... seems confusing and leads to various double negatives; it would be easier to read if this was isPseudoElement even if that means an extra ! at the call site.
There was a problem hiding this comment.
We have public Stream.noneMatch(), Files.notExists(), Objects.nonNull(), and many more non-public methods that answer a negative question; but I'll change this one if you think that it will improve readability.
There was a problem hiding this comment.
It worries me that we are removing support for a feature that had explicit positive tests.
We discussed this offline at length. The tests are not specifically for the feature, but instead, they are tests for a different feature (relative links) in a variety of situations, including the suspect case of {@inheritDoc}.
It might be worth investigating whether we can write tests for relative links when {@inheritDoc} is used in a legal position, such as on a method declaration.
There was a problem hiding this comment.
We have public
Stream.noneMatch(),Files.notExists(),Objects.nonNull(), and many more non-public methods that answer a negative question; but I'll change this one if you think that it will improve readability.
Would prefer to see it inverted, if you don't mind. There are good reasons for the negative form in the 3 cases you list, and none of those reasons apply here. Files.notExists is a fun one because it is not !Files.exists
| """ | ||
| <a href="relative-class-link.html">relative class link</a>""", | ||
| """ | ||
| <a href="#class-fragment">fragment class link</a>""", | ||
| """ | ||
| <a id="class-fragment">Class fragment</a>""", |
There was a problem hiding this comment.
Why are these lines (and similar, below) being deleted?
There was a problem hiding this comment.
Because they come from {@inheritDoc} on a class' main description. Such a use case is undocumented, unsupported, and is now being prohibited by this PR.
| /** | ||
| * Here are two relative links in a class: | ||
| * <a href="relative-class-link.html">relative class link</a>, | ||
| * <a href="#class-fragment">fragment class link</a>. | ||
| * | ||
| * <a id="class-fragment">Class fragment</a>. | ||
| */ |
There was a problem hiding this comment.
Why are these being deleted?
|
This is a general response to the edits in There are various circumstances in which relative links need to be fixed up, all related to taking content containing links from one place and using it in another. These include:
While I do not expect a full review of all these use cases, the intent of the use of |
This addresses Jon's fair concerns on me aggressively removing some test cases, that could still work.
I accept that I nixed some tests overly aggressively. I carefully returned them back in 7d540c4. Note that since If fixing up relative links needs to be tested for a top-level declaration, then they have to be tested some other way, outside of the context of this PR; do you agree? |
That's not the right question. The question is, how can we best replace the functionality of those tests. It's the relative link that's important, not the location. Since the comment containing the relative link can no longer be placed on a top level declaration, they should be moved to a declaration where they are legal, such as on a method. |
Hm... While I understand what you are saying, I also think that we already have tests that exercise relative links on methods. Those tests are located in that same directory, no? Here, test/langtools/jdk/javadoc/doclet/testRelativeLinks/pkg/C.java: |
I looked at the complete test in more detail. The test is specifically about |
| @@ -64,16 +57,6 @@ public void test() { | |||
| checkOutput(Output.STDERR, false, "at com.sun"); | |||
There was a problem hiding this comment.
This is a general comment for a followup discussion and future work.
Should we have a standard default-on check in JavadocTester for "no stack traces"? That is, the equivalent of this line here. We could model such a check on checkLinks or checkAccessibility such that a hypothetical checkNoCrashes could be disabled in the (rare?) cases that they might be expected. (For example, checking the tool/doclet behavior when a crash does occur.)
There was a problem hiding this comment.
This is a general comment for a followup discussion and future work.
While the bug and this test are about "no crashes", we should ensure that we have positive tests elsewhere for the actual output generated, assuming that no crash occurred.
There was a problem hiding this comment.
We have such a check already, but it's used specifically for snippets. If you want, we could "hoist" that check from SnippetTester into JavadocTester. However, I would prefer doing that in a separate PR.
public class SnippetTester extends JavadocTester {
...
/*
* When checking for errors, it is important not to confuse one error with
* another. This method checks that there are no crashes (which are also
* errors) by checking for stack traces. We never expect crashes.
*/
protected void checkNoCrashes() {
checking("check crashes");
Matcher matcher = Pattern.compile("\\s*at.*\\(.*\\.java:\\d+\\)")
.matcher(getOutput(Output.STDERR));
if (!matcher.find()) {
passed("");
} else {
failed("Looks like a stacktrace: " + matcher.group());
}
}
...
|
@pavelrappo This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 15 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
|
/integrate |
|
Going to push as commit 62fbc3f.
Your commit was automatically rebased without conflicts. |
|
@pavelrappo Pushed as commit 62fbc3f. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This rights the wrongs of JDK-8008768. For more information, see the respective CSR.
Progress
Issues
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk19 pull/54/head:pull/54$ git checkout pull/54Update a local copy of the PR:
$ git checkout pull/54$ git pull https://git.openjdk.org/jdk19 pull/54/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 54View PR using the GUI difftool:
$ git pr show -t 54Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk19/pull/54.diff