interactions between type annotations and language model APIs.

Joe Darcy joe.darcy at oracle.com
Fri May 9 22:38:33 UTC 2014


Hi Alex,

On 5/9/2014 2:36 PM, Alex Buckley wrote:
> Joe,
>
> On 5/9/2014 8:24 AM, Joe Darcy wrote:
>> My first reaction here is that these methods should by default ignore
>> annotations and we should add another utility method or two like:
>>
>> <T extends TypeMirror> T withAnnotations(T typeMirror, List<? extends
>> AnnotationMirror> annotations)
>>
>> <T extends TypeMirror> T withAnnotations(T typeMirror,
>> AnnotatedConstruct annotationHost)
>>
>> to allow the annotations savvy user to perform whatever annotation
>> passing along or computation is appropriate for the problem domain.
>
> In other words, specify in javax.lang.model.util.Types that it is 
> unspecified as to the presence of type annotations in a TypeMirror 
> object returned by a Types' method ?

Or even go further and state no annotations are propagated.

> And also, specify builder methods that decorate an existing TypeMirror 
> object with type annotations ?

Right.

>
> This approach sidesteps the complexities (alluded to in my prior mail) 
> of trying to enrich certain methods' results with type annotations.

Indeed.

>
> This approach also exposes that "there's more than one way to do it", 
> so we should not rush into decisions that ultimately will be part of 
> JSR 269's next Maintenance Review. Do you keep a to-do list for 269 
> somewhere?
>

Given the desired semantics of the annotations being used in these cases 
are largely extra-lingual, I don't think trying to specify their 
propagation in javax.lang.model is wise.

For tracking purposes, a JBS bug in core-libs / javax.lang.model would 
be appropriate.

Thanks,

-Joe


More information about the compiler-dev mailing list