Should @SupportedAnnotationTypes handle TYPE_USE?
Joseph D. Darcy
joe.darcy at oracle.com
Tue Sep 25 23:18:44 UTC 2018
Hi Bernard,
On 9/25/2018 2:42 AM, B. Blaser wrote:
> On Tue, 25 Sep 2018 at 05:07, joe darcy <joe.darcy at oracle.com> wrote:
>> Hi Bernard,
>>
>>
>> On 9/24/2018 3:05 PM, B. Blaser wrote:
>>> Hi,
>>>
>>> I noted that the annotation processor [1] isn't run if
>>> @SupportedAnnotationTypes ({"TA"}) is used instead of ({"*"}) because
>>> annotations on TYPE_USE don't seem to be handled when selecting
>>> processors.
>>>
>>> Is this normal or should we add something like below (to be completed)?
>>> The documentation [2] isn't clear about that.
>> The documentation of the Processor interface covers this situation:
>>
>> " Annotations on type uses, as opposed to annotations on elements, are
>> ignored when computing whether or not an annotation type is present."
>> https://docs.oracle.com/javase/10/docs/api/javax/annotation/processing/Processor.html
> Thanks Joe, I missed it :-(
> But is there any justification for this or is it planned to handle
> annotations on type use when selecting processor?
> It should be possible to do that as I showed with the draft I posted yesterday.
> Using "*" means that processors focusing on type use are always run
> which isn't what we'd expect and not optimal in performance terms...
>
The text in question was added under JDK-7162089: Add support for
repeating annotations to javax.annotation.processing.
This is the level of support for type annotations and annotation
processing that was proposed and agreed to back in 2013 when the feature
was added to the platform as part of JDK 8:
http://mail.openjdk.java.net/pipermail/type-annotations-spec-comments/2013-May/000033.html
http://mail.openjdk.java.net/pipermail/enhanced-metadata-spec-discuss/2013-May/000212.html
Supporting type annotations was not the intended design center of the
annotation processing API.
Note that it would be possible to write a TypeAnnotationProcessor which
wrapped a Processor instanced and provided the sort of functionality
you're interested in.
HTH,
-Joe
More information about the compiler-dev
mailing list