Is it possible for make the compiler generate a warning when it encounters a user defined annotaion? Something similar to the @Deprecated
annotation?
Thanks
@Deprecated @Deprecated annotation indicates that the marked element is deprecated and should no longer be used. The compiler generates a warning whenever a program uses a method, class, or field with the @Deprecated annotation.
The @Override annotation denotes that the child class method overrides the base class method. For two reasons, the @Override annotation is useful. If the annotated method does not actually override anything, the compiler issues a warning. It can help to make the source code more readable.
Based on your original question and comments, I assume you're trying to do the following:
I don't believe you can mark the code with a compiler warning. The @Deprecated
tag is baked into the compiler. A more common way of indicating a method is incomplete is by throwing an exception:
throw new UnsupportedOperationException("Not implemented yet");
The effect isn't realized until runtime, but the other developers should be unit testing their code.
As for identifying the incomplete code I would still refer back to my original comment. Use the TODO
comment tag and Eclipse will build a task list for you. If your list is cluttered with auto-generated code that hasn't been cleaned up, you can use FIXME
, XXX
, or define your own. You should then be able to filter your list.
I've asked the Lombok people to look at providing this functionality https://github.com/peichhorn/lombok-pg/issues/114 and it is now implemented ;-) https://github.com/peichhorn/lombok-pg/wiki/%40Warning
It's possible via annotation processors api
Here is Lightweight Javac Warning Annotation library https://github.com/pushtorefresh/javac-warning-annotation
Usage:
// some code...
@Warning("This method should be refactored")
public void someCodeWhichYouNeedAtTheMomentButYouWantToRefactorItLater() {
// bad stuff going on here...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With