[JSR308] Implicit annotations with values

Mahmood Ali mahmood at MIT.EDU
Fri Jul 4 19:18:45 EDT 2008


Greetings Artemus,

As of this release, the framework only constructs AnnotationMirrors with 
no values.  Hopefully, the requested feature will be added in the next 
release (next Thursday/Friday).

It is worthy to note that most of the framework classes (e.g. 
GraphQualifierHierarchy, AnnotatoinUtils, AnnotatedTypeMirror), were 
designed for annotations without values.  Specifically, any container
may hold up to one annotation of a given type regardless of its value.
(i.e. a type cannot have both annotations @A("1") @A("2")).

Regards,
Mahmood

On Fri, 4 Jul 2008, Artemus Harper wrote:

> What would be the best way to add an implicit annotation to a type, where
> the implicit annotation has some of its elements defined.
>
> My code:
> @Override
>    protected void annotateImplicit(Tree tree, AnnotatedTypeMirror type) {
>    ...
>    switch(tree.getKind()) {
>    ...
>    case NEW_CLASS:
>    if(type.getAnnotation(InnerUnique.class.getName()) == null) {
>       //I want to add @InnerUnique({"*"})
>    ...
>    }
> }
>
> where InnerUnique is:
> @TypeQualifier
> @Retention(RetentionPolicy.RUNTIME)
> public @interface InnerUnique {
>   String[] value();
> }
>
> I see that AnnotationUtils has a method to get an AnnotationMirror with no
> values defined, but I don't see any to actually set the values.
> My best guess is to simply implement AnnotationMirror my self and return the
> values I want. Is there a better way to do this?
>
> -- 
> Artemus Harper
>



More information about the JSR308 mailing list