RFR: 8174840: Elements.overrides does not check the return type of the methods
Pavel Rappo
prappo at openjdk.org
Mon Jan 6 22:04:35 UTC 2025
On Mon, 6 Jan 2025 19:12:28 GMT, Chen Liang <liach at openjdk.org> wrote:
>> Please review this PR to clarify the documentation of `Elements.overrides` through an `@apiNote`, this PR is essentially a doc-only change. This PR supersedes https://github.com/openjdk/jdk/pull/22244.
>>
>> TIA.
>
> test/langtools/tools/javac/processing/model/util/elements/overrides/S.java line 2:
>
>> 1: /*
>> 2: * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
>
> Is the beginning copyright year 2023 correct?
Yes, it is. The patch attached to the JBS issue is dated 2023. That patch is used in this PR.
> test/langtools/tools/javac/processing/model/util/elements/overrides/TestOverrides.java line 54:
>
>> 52: if (!elements.overrides(tm, sm, t))
>> 53: messager.printError(String.format(
>> 54: "%s does not override %s from %s", tm, sm, t.getQualifiedName()));
>
> This message implies `sm` is from `t`, which is not the case. Consider improving the failure message.
This uses the wording from JLS 8.4.8.1 (emphasis mine):
> An instance method `mC` declared in or inherited by class `C`, overrides **from** `C` another method `mA` declared in class `A`, iff all of the following are true:
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22920#discussion_r1904667945
PR Review Comment: https://git.openjdk.org/jdk/pull/22920#discussion_r1904681338
More information about the compiler-dev
mailing list