Lombok has introduced experimental features with version: 1.18.2 for inheritance issues faced with Builder annotation, and can be resolved with @SuperBuilder annotation as below.

@SuperBuilder
public class ParentClass {
    private final String a;
    private final String b;
}

@SuperBuilder
public class ChildClass extends ParentClass{
    private final String c;
}

Now, one can use Builder class as below (that was not possible with @Builder annotation)

ChildClass.builder().a("testA").b("testB").c("testC").build();
Answer from Amit Kaneria on Stack Overflow
🌐
Baeldung
baeldung.com › home › java › lombok @builder with inheritance
Lombok @Builder with Inheritance | Baeldung
May 11, 2024 - When using @Builder on a class that extends another class like that, we’ll get the following compilation error on the annotation: Implicit super constructor Parent() is undefined. Must explicitly invoke another constructor · This is due to the fact that Lombok doesn’t take into account the fields of the superclasses but only the ones from the current class.
Discussions

java - Lombok @Builder with inheritance that requires a certain field - Stack Overflow
Java 11, Spring Boot and Lombok here. I am trying to build up a hierarchy of objects extending Spring's ApplicationEvent class which forces me to provide a constructor: public ApplicationEvent(Object More on stackoverflow.com
🌐 stackoverflow.com
java - Lombok @builder on a class that extends another class - Stack Overflow
See in https://blog.codecentric.de/en/2016/05/reducing-boilerplate-code-project-lombok/ (@Builder and inheritance part) More on stackoverflow.com
🌐 stackoverflow.com
java - Inheritance for builders in lombok - Stack Overflow
I was trying to use lombok for my project. I have a class A: @Data @Builder public class A { Integer a1; } and a class B: @Data public class B extends A { Integer b1; @Builder ... More on stackoverflow.com
🌐 stackoverflow.com
java - Lombok @Builder inheritance for 3 Classes - Stack Overflow
This is probably a beginner question but I am getting confused. I have 3 classes as shown below. How do I use lombok's @Builder annotation in this case. I get an error in Class C when trying to ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Medium
manishkrb.medium.com › why-lomboks-builder-does-not-support-inheritance-13e3817c35aa
🧩 Why? Lombok’s @Builder does not support inheritance. | by MANISHA BHARDWAJ | Medium
May 21, 2025 - With regular @Builder, trying to build with .id() or .name() from the child class would fail to compile — because those fields are defined in the parent, and @Builder doesn't traverse the hierarchy. ... You have inheritance between classes.
🌐
Medium
medium.com › @drivaspedro › java-lombok-builder-annotation-with-inheritance-6541087040f2
Java Lombok Builder Annotation With Inheritance | by Drivaspedro | Medium
December 23, 2022 - @SuperBuilder public class Person ... } // Then instantiate the class like this: Developer developer = Developer .builder() .name("Drivas") .language("Java") .build(); This feature was introduced on the Lombok 1.18 ...
🌐
Reinhard
blog.reinhard.codes › 2015 › 09 › 16 › lomboks-builder-annotation-and-inheritance
Lombok’s @Builder annotation and inheritance | reinhard.codes
September 16, 2015 - We have been using @Builder on the class itself, but you can also put it on a class’s constructor or on a static method. In that case, Lombok will create a setter method on the builder class for every parameter of the constructor/method.
🌐
Bjoernkw
bjoernkw.com › home › software › enterprise software › inheriting properties for lombok @builders and jpa entities
Inheriting Properties for Lombok @Builders and JPA Entities | Björn Wilmsmann
January 22, 2023 - To alleviate this problem we can use @SuperBuilder, which gives us access to properties from the parent class, too, when using the builder pattern through Lombok: Similarly, when working with JPA and abstract class inheritance, we can avoid code duplication in child classes by using the @MappedSuperclass annotation (from the Jakarta Persistence API), which will inherit JPA properties like @Id or @GeneratedValue from a parent class.
Top answer
1 of 2
4

Since you can't use @SuperBuilder annotation, beacause you don't have access to ApplicationEvent class, as far as I can see, the only solution is to do something like following:

Assume that you have TrackedEvent class wich looks something like this:

public class TrackedEvent extends ApplicationEvent {
    protected String correlationId;
    protected String description;

    public TrackedEvent(Object source, String correlationId, String description) {
        super(source);
        this.correlationId = correlationId;
        this.description = description;
    }

    public TrackedEvent(Object source) {
        super(source);
    }


}

And you have OperationalEvent class wich extends above class. Than, you can implement builder pattern in OptionalEvent class like this:

public class OperationalEvent extends TrackedEvent {

    private String type;
    private String status;

    public OperationalEvent(Object source) {
        super(source);
    }


    @Builder(builderMethodName = "optionalEvent")
    public OperationalEvent(Object source, String correlationId, String description, String type, String status) {
        super(source, correlationId, description);
        this.type = type;
        this.status = status;
    }

    @Override
    public String toString() {
        return "OperationalEvent{" +
                "type='" + type + '\'' +
                ", status='" + status + '\'' +
                "correlationId:" + correlationId +
                '}';
    }
}

And than the following code should work as expected:

public static void main(String[] args) {
    ApplicationEvent applicationEvent = new ApplicationEvent(new Object()) {
        @Override
        public Object getSource() {
            return super.getSource();
        }
    };
    OperationalEvent opsEvent = OperationalEvent.optionalEvent()
            .description("something happened")
            .source(applicationEvent)
            .status("status")
            .correlationId("1")
            .build();

}
2 of 2
1

You can use @SuperBuilder together with an intermediate abstract class, as described here.

The advantage over using customized @Builders is that you only have to manually implement this single custom intermediate class once. There is no need for customization in every subclass.

In this case, the intermediate class looks as follows:

public abstract class ApplicationEventSuperBuilderEnabler extends ApplicationEvent {

    public static abstract class ApplicationEventSuperBuilderEnablerBuilder<C extends ApplicationEventSuperBuilderEnabler, B extends ApplicationEventSuperBuilderEnablerBuilder<C, B>> {
        private Object source;

        public B source(Object source) {
            this.source = source;
            return self();
        }

        protected abstract B self();

        public abstract C build();
    }

    protected ApplicationEventSuperBuilderEnabler(ApplicationEventSuperBuilderEnablerBuilder<?, ?> b) {
        super(b.source);
    }
}

Next, let all your direct subclasses extend ApplicationEventSuperBuilderEnabler (instead of ApplicationEvent) and put a @SuperBuilder on all classes:

@SuperBuilder
public abstract class TrackedEvent extends ApplicationEventSuperBuilderEnabler { ... }

@SuperBuilder
public class OperationalEvent extends TrackedEvent { ... }

Now you can use it like this:

OperationalEvent opsEvent = OperationalEvent.builder()
        .source(this)
        .description("something happened")
        .status(OperationalStatus.THE_THING)
        .build();
Top answer
1 of 5
136

Since release 1.18.2 lombok includes the new experimental @SuperBuilder. It supports fields from superclasses (also abstract ones). With it, the solution is as simple as this:

@SuperBuilder
public class Child extends Parent {
   private String a;
   private int b;
   private boolean c;
}

@SuperBuilder
public class Parent {
    private double d;
    private float e;
}

Child instance = Child.builder().b(7).e(6.3).build();

Update 2019-10-09: If you use IntelliJ, you need at least version 0.27 of the IntelliJ Lombok plugin to use @SuperBuilder.

PS: @AllArgsConstructor(onConstructor=@__(@Builder)) does not work because @Builder is an annotation-processing annotation that lombok translates to code during compilation. Generating and then translating new lombok annotation would require several iterations of annotation processing, and lombok does not support that. @Autowired, in contrast, is a regular Java annotation available at runtime.

2 of 5
66

See in https://blog.codecentric.de/en/2016/05/reducing-boilerplate-code-project-lombok/ (@Builder and inheritance part)

Adjusted to your classes

@AllArgsConstructor
public class Parent {
  private double d;
  private float e;
}

public class Child extends Parent {
  private String a;
  private int b;
  private boolean c;

  @Builder
  public Child(String a, int b, boolean c, double d, float e) {
    super(d, e);
    this.a = a;
    this.b = b;
    this.c = c;
  }
}

With this setup

Child child = Child.builder().a("aVal").b(1000).c(true).d(10.1).e(20.0F).build();

works correctly

Find elsewhere
🌐
Google Groups
groups.google.com › g › project-lombok › c › Gr1IkNNXMJI
@Builder and inheritance
Builder works with any static method or constructor and placing @Builder on the class is just a shortcut generating the @AllArgsConstructor. The Builder then handles all the arguments. But the constructor doesn't account for the superclass and this is hard to solve.
🌐
Medium
medium.com › @knoldus › how-to-deal-with-inheritance-while-using-lombok-builder-4dad3c301ee7
How to deal with Inheritance while using Lombok builder | by Knoldus Inc. | Medium
June 26, 2019 - If we change the name of the builder of any one class, then we will be able to solve this problem. To give a custom name to the builder, we can use the builder argument builderMethodName and assign it to a builder name.
🌐
iO Flood
ioflood.com › blog › lombok-builder
Lombok @Builder | Streamlining Java Object Creation
March 5, 2024 - One of the powerful features of Lombok’s @Builder annotation is its compatibility with inheritance.
🌐
Itechguides
itechguides.com › home › blog › how to use lombok @builder with inheritance in java
How to Use Lombok @Builder with Inheritance in Java
August 18, 2026 - How to use Lombok @Builder with inheritance in Java: use @SuperBuilder on every class so one builder can set superclass and subclass fields. Includes Maven, Gradle, toBuilder, troubleshooting, and alternatives.
🌐
CodingTechRoom
codingtechroom.com › question › using-lombok-s-builder-with-inheritance-a-guide
How to Use Lombok @Builder with Inheritance in Java - CodingTechRoom
Lombok requires all parameters to be defined and passed up to the parent class constructor when using the @Builder annotation with inheritance.
🌐
GitHub
github.com › peichhorn › lombok-pg › issues › 78
@Builder should work with inheritance · Issue #78 · peichhorn/lombok-pg
April 22, 2012 - Would be nice to also have a way to specify extra attributes in the builder to be used in the superclass constructor call. Or if the superclass has a builder it would be nice use this builder when creating the builder of the subclass.