This discussion is archived
2 Replies Latest reply: Nov 12, 2009 9:55 PM by 843793 RSS

how to trigger my own annotation like @Deprecated?

843793 Newbie
Currently Being Moderated
seems that only compiling classes which use my own annotations will trigger my annotation processor, is there any way to trigger my annotation processor like @Deprecated does? that is when using something which has been annotated will trigger my annotation processor?

Class Test
{
@myannotation
public a()
{
}
}

Class Testb
{
Test t = new Test();
t.a();
}

when compiling Testb, it will trigger my annotation processor.
  • 1. Re: how to trigger my own annotation like @Deprecated?
    843793 Newbie
    Currently Being Moderated
    i found that in java 6 annotation processor SDK, you can define your processor to apply to all annotation types (@SupportedAnnotationTypes('*')), then even compiling a class file with no annotation used, your processor will be triggered.

    however, seems we still can't get information we need through javax.lang.model.element.
  • 2. Re: how to trigger my own annotation like @Deprecated?
    843793 Newbie
    Currently Being Moderated
    efinal wrote:
    i found that in java 6 annotation processor SDK, you can define your processor to apply to all annotation types (@SupportedAnnotationTypes('*')), then even compiling a class file with no annotation used, your processor will be triggered.
    * Correct; supporting "*" will claim all annotations, even an empty set.

    Your processor can also support "java.lang.Deprecated" too.
    however, seems we still can't get information we need through javax.lang.model.element.
    Not sure what you mean by that.