Checking annotations in enum types

3 views
Skip to first unread message

Ales Plsek

unread,
Nov 29, 2009, 8:24:00 PM11/29/09
to Type annotations (JSR 308) discussions
Hi all,

we have a problem when checking annotated enum types.
E.g. for enum where each keyword is annotated as well:

public @SCJAllowed enum Level {
@SCJAllowed
LEVEL_0 {
@Override
public int value() {
return 0;
}
},
...
}

When the checker calls our visitClass method, we receive a node that
is:
public enum Level {
/*public static final*/ LEVEL_0 /* = new Level()/*enum*/{

() {
super();
}

@Override()
public int value() {
return 0;
}
} */,

However, in this node, all our @SCJAllowed annotations are lost. For
example the whole LEVEL_0 should have an annotation, same for the
constructor.

It seems to me that enums are handled by the checker somehow
differently then the other types. Are we annotating them in a wrong
way?

Thank you for any help.

Regards,
Ales

Mahmood Ali

unread,
Dec 2, 2009, 12:12:58 AM12/2/09
to jsr308-discuss
Greetings Ales,

Thank you very much for reporting this bug. I will look into this further.

My first intuition is that annotations on enum values are declaration
annotations, not type annotation, as they don't really target a type,
and treating it as such would require an additional check that the
annotated type of the enum value is a subtype of the enum type.

Thanks again.

Regards,
Mahmood
Reply all
Reply to author
Forward
0 new messages