When are Java annotations executed?

后端 未结 7 2147
执念已碎
执念已碎 2021-02-06 04:12

I am just looking to write some annotation which can execute at runtime, before or immediately after a service method is invoked.

I don\'t know if they are executed at r

7条回答
  •  萌比男神i
    2021-02-06 04:46

    1. Annotations are only markers at the source code. They will be used by tools like IDE, compiler or annotation processors.

    2. You can define with @Retention if a annotation should be evaluated in the source, class or runtime.

    3. If you would like define your owned annotations and only you has the knowledge what the annotation should be do, so you should write an annotation processor too. (but this is not simple - maybe)

提交回复
热议问题