使用GetAnnoations()方法时,未识别Lombok @getter和@setter注释
Lombok @getter和@setter注释在GetAnnoations()方法中都未被识别,并通过反射为变量。关于如何使用反射测试是否存在这些注释的任何建议?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法在运行时检查这些注释,因为它们是仅编译时间的注释(
retention-policy.source
),这些注释由编译器丢弃,因此在编译的类文件中不存在。在运行时找不到找出六个二阶/Getter方法是由Lombok生成还是手动书写。
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.