Home > database >  Lombok @Getter and @Setter annotations are not being recognised when getAnnoations() method is used
Lombok @Getter and @Setter annotations are not being recognised when getAnnoations() method is used

Time:04-27

Lombok @Getter and @Setter annotations are not being recognised when getAnnoations() method is used with a variable by reflection. Any suggestions on how to test if these annoations are present using reflection?

CodePudding user response:

You cannot check for those annotations during runtime, as they are compile-time-only annotations (RetentionPolicy.SOURCE) which are discarded by the compiler and thus not present in the compiled class files.

There is no way to find out during runtime whether a setter/getter method was generated by lombok or written manually.

  • Related