documentation home

FAQ  Lombok's @Builder annotation causes a cannot find symbol error during the javadoc phase.


Problem

You get the following error during the javadoc phase when using Lombok's @Builder annotation.

javadoc: Constructing Javadoc information...
cannot find symbol
  symbol:   class FooBuilder
  location: class com.example.Foo

This happens when you use the builder class as a parameter type or return type.

Solution

Javadoc is not aware of the code modifications made by Lombok. There are two possible solutions:

  • Using delombok to generate source code that can be accessed during the javadoc phase. See the delombok page for further information.
  • Manually adding the inner builder class without an implementation.

Using delombok generates additional source code that needs to be maintained manually and might not be desirable. So as an alternative, you could manually add a static inner class inside the class that uses the @Builder annotation. For example:

@Builder
public class Foo {

    // fields and methods

    public static class FooBuilder {};
}

This static inner class is normally generated by Lombok. By manually adding this inner builder class, it will satisfy javadoc and won't interfere with the @Builder annotation's normal behaviour. Lombok will simply fill out the remainder of the builder class.