r/java • • Oct 05 '23

How does the lombok magic work underneath?

https://www.unlogged.io/post/how-does-the-lombok-magic-work-underneath
133 Upvotes

143 comments sorted by

View all comments

Show parent comment

2

u/rzwitserloot Oct 05 '23

The exact same problem (whoops, I tossed a casual annotation out there and now my DB code goes nuts) can also occur in reflective based JPA implementations, and can also occur with non-"edit existing files" annotation processors such as the Immutables project. I don't think "the problem with APs being able to edit existing source files vs. only allowed to make new ones" is that this is somehow 'self modifying code'.

1

u/koflerdavid Oct 09 '23

That's really just a criticism about these project's API design and because these are annotations with runtime effects. While they are undoubtedly powerful and useful, many programmers have become wary about the pitfalls of Hibernate and Spring Data, and how large a difference a stray annotation can make. In the case of Immutables, an error usually results in a compilation failure.