[jdk19] Integrated: 6509045: {@inheritDoc} only copies one instance of the specified exception
Pavel Rappo
prappo at openjdk.org
Wed Jul 6 22:05:45 UTC 2022
On Wed, 6 Jul 2022 17:05:19 GMT, Pavel Rappo <prappo at openjdk.org> wrote:
> This is the second of the two PRs that fix inheritance for multiple `@throws` tags for a particular exception.
>
> The first PR (8067757, #95) fixed inheritance for multiple `@throws` tags for an exception referred to by a `throws` clause. This PR fixes inheritance for multiple `@throws` tags for an exception referred to by an `@throws` tag.
>
> It is expected that if an overriding method has an `@throws` tag that has an `{@inheritDoc}` in its description, then the documentation will inherit all tags that describe that same exception in the overridden methods. For example, support the setup looks like this:
>
> * Overrider
> ```
> @throws NullPointerException if this
> @throws NullPointerException if that
> ```
>
> * Overridee
> ```
> @throws NullPointerException {@inheritDoc}
> ```
> Then the overridee's documentation should look like this:
>
> Throws:
> NullPointerException - if this
> NullPointerException - if that
>
>
> While logical and expected, such behavior is different from other use cases of `{@inheritDoc}`. In other use cases `{@inheritDoc}` expands locally: it replaces itself with a list of tree nodes. Such a replacement doesn't affect any tree node other than its parent.
>
> `{@inheritDoc}` expands locally everywhere, such as in the main description, `@param`, and `@return` tags, but it is not enough for `@throws`, which sometimes needs to amend the **grandparent** node to replace a `@throws` node with multiple `@throws` nodes. Amending this behavior globally just for `@throws` would be impractical.
>
> For now, it seems reasonable to fix this by overriding the `{@inheritDoc}` processing just for `@throws`. This PR gives `ThrowsTaglet` an ability to peek at `@throws` description to see if there are any `{@inheritDoc}` there.
>
> There's one limitation though. Suppose `@throws` documentation is both amended and inhertied from multiple `@throws` like this:
>
> * Overridder
>
> @throws NullPointerException if this
> @throws NullPointerException if that
>
>
> * Overridee
>
> @throws NullPointerException "{@inheritDoc}"
>
>
> It's not clear what to do in such a case. If only one of either amendment (a `"` quote before and after) or multiple-inheritance is present, it's clear what to do. But not when both are present. For now, such a situation is detected and flagged as an error (a test is provided).
This pull request has now been integrated.
Changeset: 8f24d251
Author: Pavel Rappo <prappo at openjdk.org>
URL: https://git.openjdk.org/jdk19/commit/8f24d25168c576191075c7344ef0d95a8f08b347
Stats: 271 lines in 2 files changed: 261 ins; 2 del; 8 mod
6509045: {@inheritDoc} only copies one instance of the specified exception
Reviewed-by: jjg
-------------
PR: https://git.openjdk.org/jdk19/pull/116
More information about the javadoc-dev
mailing list