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,080
  • 37
  • 126
  • 190

4 Answers4

3

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

Aaron Digulla
  • 310,263
  • 103
  • 579
  • 794
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,193
  • 3
  • 31
  • 47
2

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

Jerome
  • 8,339
  • 2
  • 31
  • 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
  • 572,413
  • 138
  • 1,043
  • 1,132