Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Define annotation only applicable to static methods

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!

like image 463
Nico Huysamen Avatar asked Jan 19 '23 21:01

Nico Huysamen


1 Answers

In short, no. But whatever code is processing the annotation can check that the method it's attached to is static.

like image 75
dty Avatar answered Jan 22 '23 10:01

dty