On Mon, 12 May 2025 14:46:39 GMT, Nizar Benalla <nbena...@openjdk.org> wrote:

>> Please review this patch to fix a bug where a method can be documented 
>> multiple times 
>> Consider these 4 classes
>> 
>>                     A       (interface)
>>                    / \
>>                   /   \
>> (abstract class)  C     B   ( interface)
>>                   \   /
>>                    \ /
>>                     D       (class)
>> 
>> 
>> Where `A` declares `testA()`, `C` implements it `public final void testA()`, 
>> `B` extends `A` but does *not* override it, `D` extends `C` and implements 
>> `B`
>> 
>> In the generated javadoc, `testA()` is documented twice.
>> 
>> ![Screenshot 2025-05-08 at 15 51 
>> 19](https://github.com/user-attachments/assets/46538e61-1546-4128-8041-296d8491406f)
>> 
>> After the patch, `testA()` is only documented once:
>> 
>> ![Screenshot 2025-05-08 at 15 52 
>> 16](https://github.com/user-attachments/assets/a6b86a21-7104-460c-8f3f-36cee5962eed)
>
> Nizar Benalla has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   rename test to be more accurate and simplify code

I have to apologize for my previous review. When I noticed that JDK 
documentation had changed, my knee-jerk reaction was that the fix was wrong. 
But it is indeed the current documentation that is wrong. 

For example in 
[StringBuilder](https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/lang/StringBuilder.html#methods-inherited-from-class-java.lang.Object),
 the methods overridden in the hidden `AbstractStringBuilder` class should not 
be shown as declared in `CharSequence` as they are documented is if they were 
local methods in `StringBuilder.

Similarly (but without the hidden superclass), the `equals` and `hashCode` 
methods in 
[HashMap](https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/util/HashMap.html#methods-inherited-from-class-java.util.AbstractMap)
 should not be documented as declared in interface `Map`, but only in 
`AbstractMap` where they override the default implementation.

So your first solution (in the simplified form) was actually correct after all.

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

PR Comment: https://git.openjdk.org/jdk/pull/25123#issuecomment-2916427310

Reply via email to