Hello Lombok team,
In many Spring Boot projects, we follow a common pattern:
We define a @Component or @Service as an implementation of an interface
It often extends an abstract base class that contains shared logic
That base class has final dependencies injected via constructor (annotated with @RequiredArgsConstructor)
Example:
We repeat this pattern frequently. But Lombok currently can’t help us generate constructors that:
call the superclass constructor with its required fields
assign subclass final fields
This results in a significant amount of repetitive and error-prone boilerplate code in subclass constructors.
ProposalIntroduce support for automatic constructor generation in subclasses, such as:
@RequiredArgsConstructor(callSuper = true)
or a new annotation like @SuperRequiredArgsConstructor
This would instruct Lombok to:
include all final fields from the subclass
call the only constructor of the superclass (if and only if it has exactly one constructor)
To avoid ambiguity:
BenefitThis feature would only be available when the superclass has exactly one constructor.
In other cases, Lombok would fail compilation and require explicit constructor definition by the developer.
This small enhancement would be a big productivity boost in Spring-based codebases that heavily rely on constructor injection and inheritance-based composition. It enables clean, consistent, and DRY code.
Would this be feasible to implement?
Thanks for your excellent work — Lombok is indispensable in modern Java projects.
Best regards,
Robert Fišer