[External] : Re: RFR: 8231436: Fix the applicability of a no- at Target annotation type
Alex Buckley
alex.buckley at oracle.com
Sat Feb 6 00:51:54 UTC 2021
On 2/5/2021 4:18 PM, Liam Miller-Cushon wrote:
> I don't have a strong opinion either way about whether this change is
> worth pursuing, or worth pursuing now. The simplicity of @Target-less
> annotations applying to everything is appealing. I also think there's
> going to be some noticeable compatibility impact, due to the number of
> annotations that will start appearing in type contexts, and the number
> of tools that process annotations that will need to become more robust
> in their handling of type annotations.
Suppose that the no- at Target annotation @Foo is today a declaration
annotation on a method declaration, but tomorrow (due to recompiling Foo
and the aforementioned method declaration) @Foo becomes a declaration
annotation _and a type annotation that applies to the return type of the
method_. Hardly any annotation processor will care, because it'll be
calling Method::getAnnotations that only exposes declaration
annotations. Type annotations are exposed by a different API,
Method::getAnnotatedReturnType & friends.
Of course a type-checking annotation processor might be calling
Method::getAnnotatedReturnType to look for, say, @NonNull, but I have a
hard time believing that such a processor will be unable to cope with
@Foo's presence. And the owner of Foo can choose at any time to add an
@Target that makes @Foo appear as both declaration and type annotation.
Is there a compatibility impact I am overlooking?
Alex
More information about the compiler-dev
mailing list