RFR: 8370800: Downgrade cant.attach.type.annotations diagnostics to warnings [v8]
Jan Lahoda
jlahoda at openjdk.org
Tue Nov 11 15:05:50 UTC 2025
On Sun, 9 Nov 2025 18:30:53 GMT, Liam Miller-Cushon <cushon at openjdk.org> wrote:
>> Hi, please consider this fix for [JDK-8370800: Downgrade cant.attach.type.annotations diagnostics to warnings](https://bugs.openjdk.org/browse/JDK-8370800).
>>
>> As discussed in the, this reduces the compatibility impact of these diagnostics for builds that deliberately omit transitive annotation dependencies, for example if they are only referenced through javadoc `@link` tags, or by frameworks that conditionally load the classes.
>>
>> The PR changes the existing error diagnostic to an unconditional warning. Another alternative would be to make it an optional xlint diagnostic, perhaps as part of `-Xlint:classfile`, or as another category.
>
> Liam Miller-Cushon has updated the pull request incrementally with one additional commit since the last revision:
>
> Complete symbols returned by getAllMembers
If it was only for methods (and possibly fields), then using the completers might work at this time, as we don't use completers on those for anything else (I think!). If we ever wanted to use the completers on methods/fields for anything else, then might get into a hard-to-solve state. (Overall, using completers and very carefully calling complete at specific times but not otherwise to avoid errors feels a bit subtle - the current behavior of completers is already pretty complex.)
For classes, completing is done often and at "arbitrary" points in time - we could not use the same trick there. And I am not sure if we could attach TAs on classes eagerly. E.g. enhancing your test with:
class B<T extends @Anno A<String>> {
..
would lead to a failure, while having:
class B<T extends A<String>> {
...
would not, I think.
I was thinking if we could attach the TAs without completing the types (which would allow us to keep the same behavior that is present without the TAs), but I didn't see a reasonable way to do that.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/28018#issuecomment-3517334189
More information about the compiler-dev
mailing list