Is there any way to define an annotation in Java that can only be used on static methods? For example, using:
@Retention(RetentionPolicy.METHOD)
enables you to specify that the annotation can only be used on methods, but what about static methods?
Thanks!
In short, no. But whatever code is processing the annotation can check that the method it's attached to is static.
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