1

If I create a custom annotation like this:

public @interface TODO
{
    String msg();    
    String start_date();
}

then a method:

@TODO
(
   msg="will be developed!",
   start_date="05/01/2010"
)
public static void Calculator()
{
}

after I call it:

Calculator();

If I wanted that the compiler warn me about it how could I do that?

xdevel2000
  • 20,780
  • 41
  • 129
  • 196

4 Answers4

3

You must write an annotation processor and invoke apt to run it on your code.

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
3

There was a similar question, some weeks ago. Here is the link to both the question and my answer.

You can easily adapt this code to your needs.

Community
  • 1
  • 1
barjak
  • 10,842
  • 3
  • 33
  • 47
2

Use the Annotation Processing Tool (apt) to make your own AnnotationProcessor and print the message with javax.annotation.processing.Messager

Jerome
  • 8,427
  • 2
  • 32
  • 41
1

If you are using an IDE, there are plenty of good options. For Eclipse:

  • use the built-in plug-in which locates all TODO, FIXME, etc. words in your code and puts them in a special view.
  • register your own custom builder which can show you the warnings
Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140