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

As a workaround you may use Java Field Watchpoint. In such a case every access/modification of the field will result in a break point.

The disadvantage of this approach is getting a thread suspension both when you access/modify the field directly or using getter/setter methods.

However, when you catch a breakpoint using setter methods, IDEA also shows a parameter (with the same name as the field used for the watch point) in Variables window and the breakpoint is shown not in the field's line, but in the class' line.

Setter Break point

The following short description, how to create a field watch point, was copied from https://www.jetbrains.com/idea/help/creating-field-watchpoints.html:

  1. On the main menu, choose Run | View Breakpoints, or press Ctrl+Shift+F8.
  2. In the Breakpoints dialog box that opens, click add (plus icon) button.
  3. Select Field Watchpoint from the drop-down list: "Java Field Watchpoints"
  4. In the Add Field Watchpoint dialog box that opens, specify the following:
    Fully qualified name of a class that contains the desired field. You can type it manually, or click browse Button, and find the desired class by name, or from the project.
    Field name. You can type it manually, or click browse Button and select the desired field from the list of fields in the selected class.
  5. Also, you may set other options like Field access (for getters) or Field modification (for setters)

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.


Breakpoints work on implicit funcions. delombok feature allows generate implicit implementation (After debugging you could/should revert maiden changes). To make implicit implementation just right-click on class name and select the following menu line:

enter image description here