Suppose I have an interface and many classes implementing that interface. I want to enforce the overriding of the default implementation of toString() in each of those classes (that is, if some classes do not override it, that should result in a compilation error).
Is it possible to achieve that? Declaring public abstract String toString();, with or without the @Override annotation, in the interface body, is legal, but does not have any effect.
Write an annotation and annotation processor and use it during compilation.
Your annotation will look like:
and your annotation processor will look for any class that