1

I'm currently learning about Android annotation topic. I have read this "A retention policy determines at what point annotation should be discarded." My question is why do Java need to discard an annotation at some point? or for what purpose?

ref: https://www.java2novice.com/java-annotations/retention-policy

feridok
  • 648
  • 7
  • 26
duy hoang
  • 59
  • 8

1 Answers1

2

Some annotations are just for compile time (so compiler can do bunch of things like generating code (ButterKnife and Dagger) or showing warnings (like DrawableRes), helping auto complete for IDE like IntDef) and won't be used in run time. So they will be discarded.

feridok
  • 648
  • 7
  • 26
  • check this for example: https://stackoverflow.com/questions/2146104/what-is-annotation-processing-in-java – feridok Aug 05 '19 at 10:09