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?
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.
You must write an annotation processor and invoke apt
to run it on your code.
Use the Annotation Processing Tool (apt) to make your own AnnotationProcessor and print the message with javax.annotation.processing.Messager
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
精彩评论