[jdk19] RFR: 8287379: Using @inheritDoc in an inapplicable context shouldn't crash javadoc [v5]

Pavel Rappo prappo at openjdk.org
Mon Jul 11 15:43:19 UTC 2022


On Mon, 11 Jul 2022 15:36:47 GMT, Jonathan Gibbons <jjg at openjdk.org> wrote:

>> test/langtools/jdk/javadoc/doclet/InheritDocForUserTags/DocTest.java line 57:
>> 
>>> 55:         // javadoc does not report an exit code for an internal exception (!)
>>> 56:         // so monitor stderr for stack dumps.
>>> 57:         checkOutput(Output.STDERR, false, "at com.sun");
>> 
>> 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.)
>
> 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.

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());
        }
    }

    ...

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

PR: https://git.openjdk.org/jdk19/pull/54


More information about the javadoc-dev mailing list