We are using Project Lombok in a large project, and I thought I should write a few lines about it. I think it is a really nice idea, but it also causes a lot of troubles. For those who don’t know project lombok: It creates a lot of bytecode for you, you just have to annotate your java classes. For example, you can write a java class like:

@Data public class MyBean() {
    private final String foo;
    private String bar;
    private int foobar;
}

Project lombok will then create getters and setters for all private variables, a constructor to initialize all final fields, a nice toString() method and a correct hashCode() method. The cool thing is that it does not create any source code. Instead, project lombok hooks itself into the java compiler and creates the byte code for all these methods.

The bad thing about this is that it is an “ugly hack”. They use undocumented features of the java compiler, and you need a special eclipse plugin to make compilation work in eclipse.

This eclipse plugin breaks some of useful features of eclipse:

  • It breaks CTRL+Shift+g: "References in Workspace" is a feature of eclipse I use really often. But since you don't have any get/set methods anymore, you can not invoke it from the code. Invoking this search from the quick outline (CTRL+o) doesn't seem to work either. You can invoke it from the outline view, but I normally don't have this view enabled, because my eclipse is already cluttered enough.
  • It breaks eclipse code generation: Generating code (like the serialVersionId or creating methods from an interface/abstract super class) doesn't work correctly anymore. All generated code is inserted before the beginning of the class.
  • It breaks refactoring: Refactoring is impossible. The only way you can change a lombok-property is by renaming the private variable, and then fixing all compiler errors where the old methods are called.
  • It breaks inheritance: A lombok @Data bean can not extend another @Data bean if the base class has final fields, because lombok doesn't create the correct constructor / super call in the derived class.

So, my conclusion is: While project lombok saves you from writing some boiler plate code, it causes more problems than it solves. Especially because I never write getters, setters, equals, hashCode or toString myselft: Eclipse does this for me, and it works fine.