Redo of backport of JDK-8225377 (type annotations are not visible to javac plugins across compilation boundaries)
Chris Povirk
cpovirk at google.com
Mon Jul 29 14:08:29 UTC 2024
Manu spoke about the ability to annotate different positions (e.g.,
type-parameter bounds) for improved nullness checking. I'd also call out
that this affects even users who use nullness annotations on "basic"
locations like fields, parameters, and return types: Unless tools use
internal javac APIs, type-use annotations in even these basic locations in
class files are invisible until JDK 22. (And as Josiah points out, this
affects more tools than just "nullness checkers." We've also seen it with
AutoValue
<https://github.com/google/auto/blob/main/value/userguide/index.md>.) This
means that type-use annotations are worse than declaration annotations in
some ways, even as they're better in others. As a result, users can't
confidently pick even a set of nullness annotations without evaluating the
tradeoffs. It would be great to be able to tell users "Use type-use
annotations" without waiting for them all to update to JDK 22.
Plus: Even if the fix is backported today, experience shows that users will
also have to wait for some annotation processors to be enhanced to start
looking for type-use annotations _at all_. I'd be happy to see us continue
to drive that positive feedback loop: As type-use annotations become more
visible to annotation processors, tools increasingly get modified to
recognize them, leading to more adoption of type-use annotations and more
opportunity to identify and iron out remaining wrinkles.
Thanks,
Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20240729/d1024a33/attachment.htm>
More information about the compiler-dev
mailing list