How to set a breakpoint in a setter method in IntelliJ IDEA that is generated with Lombok?

hibernate, intellij-idea, java, lombok

Solution

In my understanding you can't do that because lombok is mutating your bytecode in a way that mutated code doesn't have line numbers for auto-generated parts.

This is done on purpose to always have your source code lines match your bytecode. It they doesn't match, you'll may get caught in a situation when you placing your breakpoints on a line but execution didn't stop or stops somewhere else (because of line numbers mismatching).

But in exchange Lombok loses the ability to debug generated code (you can't place breakpoint on a line without line number). You have to rely on a fact that generated code is correct.

Problem

Is there a way in IntelliJ IDEA to set a breakpoint in a setter method that is generated by Lombok? This would be very useful in certain debugging scenarios, e.g. to see when the setter is called from a framework like Hibernate. In fact, the generated setter methods are displayed in the structure view of IntelliJ IDEA (Lombok plugin in use). But I've not found a way to set a breakpoint via the context menu or such.

Original source